note 36828 added to function.serialize

From: Date: Thu, 23 Oct 2003 22:35:51 +0000
Subject: note 36828 added to function.serialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-59193@lists.php.net to get a copy of this message
One problem with serialize() is that by default it does NOT alter the object, so nothing prevents you from continuing using you object after serialize()'ing it. After a while, you or someone else decides to optimize storage of this object and add a __sleep and __wakeup functions; now, serialize()'ing this same class calls __sleep() member function, potentially changing the object - old code unexpectedly breaks. Possible solutions: in the above scenario old code would most likely still work if __sleep() only creates new object variables, not altering existing ones. Another option is to always call __wakeup(), if it exists, after each serialize(), or immediately destroy the object if it is no longer used. ---- Manual Page -- http://www.php.net/manual/en/function.serialize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36828 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36828&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36828&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59193) next »