note 48766 deleted from language.oop.magic-functions by danbrown

From: Date: Sat, 07 Nov 2009 18:54:57 +0000
Subject: note 48766 deleted from language.oop.magic-functions by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162505@lists.php.net to get a copy of this message
Note Submitter: ---- There is a weird behavior occuring when serializing/unserializing a class derived from a (abstract) base class. The base may not unserialize itself if it has private members, because even if the derived class' __wakeup function is contains only parent::__wakeup() as its code, the unserialization takes place from the children's __wakeup() function and the parent's __wakeup() wont be called (as of php 5.0.3) and hence, private members from the parent wont ever be restored, even though they do serialize properly. This might/might not be a bug, but it is evil and is works not nicely with object oriented concepts. A workaround would be to put the base class' members protected or to (un)serialize manually the base class' via its derived class' __sleep() and __wakeup()

« previous php.notes (#162505) next »