note 29004 added to language.oop.magic-functions
| From: | rkelly at NO dot whitley dot unimelb dot SPAM dot edu dot au | Date: | Thu, 30 Jan 2003 03:56:24 +0000 |
| Subject: | note 29004 added to language.oop.magic-functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43115@lists.php.net to get a copy of this message | ||
The documentation above says this function is 'supposed' to return an array with the names
of variables to be saved. What this in reality means is that if you dont, bad things will happen.
I had forgotten to return the requested array after using __sleep to shutdown LDAP connections in an
object, and was attempting to save the object as part of a session.
Since __sleep was not returning anything, the serialisation was evidently not returning anything
either. This broke the stored session data, as one of the fields was completely missing and the
unserialize parsing then failed. Only by hacking through the serialised session data by hand was I
able to track down the error, and my silly mistake.
Perhaps PHP should have some way of dealing with this eventuality (treat it like an empty array?) so
that it doesnt break sessions...?
Anyway, hopefully this might save a few people the hours of headache I just went through. Make sure
you return something from this function!
--
http://www.php.net/manual/en/language.oop.magic-functions.php
http://master.php.net/manage/user-notes.php?action=edit+29004
http://master.php.net/manage/user-notes.php?action=delete+29004
http://master.php.net/manage/user-notes.php?action=reject+29004