Image

Imagejabberwokky wrote in Imagephp

Not quite a simple question

Found an interesting issue with PHP. Tested with 4, verified this behaviour. [Edit: Oops - nevermind - this was a quirk of PHPA, not PHP]

When an object is serialized, if the class is altered, and the object ia restored (unserialized), new methods are available. Wonderful for storing objects in a database, and something that I've relied on for quite awhile; the manual even covers this in pretty good detail, and you have the special __wakeup and __sleep methods. Pretty standard stuff... but...

If you extend a parent class to a child class, create an object based on that child class, serialize and store it, and then alter the *parent* class, the new methods do not appear, and any renamed methods silently vanish. Ouch. I can get a semiworkaround (read: poorly done hack) by creating a dummy method in the child class and rename it each time I alter the parent class. Unfortuantly, with several dozen classes that all extend a base class, and hundreds, soon to be tens of thousands of stored objects in the database, that's not a real solution.

Can anybody think of a way to "nudge" the object to recognize the new methods in the parent class? Preferably something that I can put into the base class's __wakeup method?