note 105005 added to class.arrayobject
| From: | marijn at sensimedia dot nl | Date: | Thu, 21 Jul 2011 19:34:53 +0000 |
| Subject: | note 105005 added to class.arrayobject | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181766@lists.php.net to get a copy of this message | ||
A gotcha that is indeed mentioned in the manual, but isn't readily obvious and just cost me
half an hour:
Objects implementing the Serializable interface do NOT get __sleep and __wakeup called; instead,
they use serialize and unserialize methods, respectively (why, I don't know, but whatever -
I'm sure there's a reason).
Hence, I was trying to serialize a database resultset in an object extending ArrayObject, and needed
to fix some stuff regarding database resources on serialize. Took me a while to figure out __sleep
wasn't getting called because ArrayObjects implements Serialize...
Presumably the ArrayObject internally implements the serialize/unserialize methods (in a trivial
manner), hence the error wasn't apparent immediately (i.e., no fatal error was thrown) and
I'd been trying to track why my objects didn't get serialized (they were of course)
instead of renaming and fixing the methods.
----
Server IP: 69.147.83.197
Probable Submitter: 78.27.38.24
----
Manual Page -- http://www.php.net/manual/en/class.arrayobject.php
Edit -- https://master.php.net/note/edit/105005
Del: integrated -- https://master.php.net/note/delete/105005/integrated
Del: useless -- https://master.php.net/note/delete/105005/useless
Del: bad code -- https://master.php.net/note/delete/105005/bad+code
Del: spam -- https://master.php.net/note/delete/105005/spam
Del: non-english -- https://master.php.net/note/delete/105005/non-english
Del: in docs -- https://master.php.net/note/delete/105005/in+docs
Del: other reasons-- https://master.php.net/note/delete/105005
Reject -- https://master.php.net/note/reject/105005
Search -- https://master.php.net/manage/user-notes.php