note 42905 deleted from language.oop.serialization by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:12:59 +0000 |
| Subject: | note 42905 deleted from language.oop.serialization by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162605@lists.php.net to get a copy of this message | ||
Note Submitter: evan dot php dot net at timewarp dot org
----
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.