Prevent a server crash when using together APC cache and Mcrypt

SVN:trunk[2498]
This commit is contained in:
Denis Flaven
2012-12-04 14:01:51 +00:00
parent 1e155ffc13
commit 442c0d6956
2 changed files with 26 additions and 3 deletions

View File

@@ -1609,6 +1609,22 @@ class AttributeEncryptedString extends AttributeString
self::$sKey = MetaModel::GetConfig()->GetEncryptionKey();
}
}
/**
* When the attribute definitions are stored in APC cache:
* 1) The static class variable $sKey is NOT serialized
* 2) The object's constructor is NOT called upon wakeup
* 3) mcrypt may crash the server if passed an empty key !!
*
* So let's restore the key (if needed) when waking up
**/
public function __wakeup()
{
if (self::$sKey == null)
{
self::$sKey = MetaModel::GetConfig()->GetEncryptionKey();
}
}
protected function GetSQLCol() {return "TINYBLOB";}