note 48766 added to language.oop.magic-functions
| From: | php-general at lists dot php dot net | Date: | Thu, 06 Jan 2005 16:09:22 +0000 |
| Subject: | note 48766 added to language.oop.magic-functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82843@lists.php.net to get a copy of this message | ||
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()
----
Manual Page -- http://www.php.net/manual/en/language.oop.magic-functions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48766
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48766&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48766&report=yes
Search -- http://master.php.net/manage/user-notes.php