note 42905 added to language.oop.serialization
| From: | evan dot php dot net at timewarp dot org | Date: | Thu, 03 Jun 2004 07:45:42 +0000 |
| Subject: | note 42905 added to language.oop.serialization | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70751@lists.php.net to get a copy of this message | ||
A special gotcha for unserializing stored objects. If you alter the class (adding new methods),
they will appear and be available when the object is unserialized. If, however, you alter the
parent class that the class extends, the methods are *not* available, and any renamed ones silently
vanish (the method disappears and does not reappear under the new name).
A way to get around this is to create a new dummy method in the child class and rename it each time
you alter the parent class. This is very much a Bad Solution when you have to deal with a base
class that is extended by dozens of other classes. Especially when you have a database full of
serialized objects, each of which is a child of the base class. There appears to be no runtime fix.
Applies to PHP 4. Not sure about 5.
----
Manual Page -- http://www.php.net/manual/en/language.oop.serialization.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42905
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42905&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42905&report=yes
Search -- http://master.php.net/manage/user-notes.php