From: rob at cue dot cc Operating system: Mac OSX 10.3.2 PHP version: 5.0.0b2 (beta2) PHP Bug Type: Session related Bug description: unexpected __sleep() serialization behavior
Description: ------------ I have an object instance ($obj_root) that I want to persist in a session. The object's class (object_container) defines the __sleep() function, and returns the array of member variables to be serialized. function __sleep() { return array("objs"); } The member variable 'objs' ($this->objs = array('foo');) is not serialized as expected; Arrays or other object-types result in null strings. Upon comparing the serialized instance strings, I have discovered that the string-ified names of the member variables are very different: serialize() without __sleep() wraps null chars around the instance class name, followed by the member variable name. obj_root|O:16:"object_container":1:{s: 22:"[EMAIL PROTECTED]@objs";a:1:{s:3:"foo" .... serialize() with __sleep() uses the plain member variable name, and dismisses it as null. If I use the __sleep() function and supply the member variable name with null chars quoting the class name the serialization works. function __sleep() { return array("\0object_container\0objs"); } Could this be a bug, or should the documentation be updated to reflect this curious behaviour of __sleep(). -- Edit bug report at http://bugs.php.net/?id=26737&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26737&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26737&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26737&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26737&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26737&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26737&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26737&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26737&r=support Expected behavior: http://bugs.php.net/fix.php?id=26737&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26737&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26737&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26737&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26737&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26737&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26737&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26737&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26737&r=float