#36172 [Opn->Csd]: subclass serialization of parent private members
ID: 36172
Updated by: degeberg@php.net
Reported By: php at justin dot meagerman dot net
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: linux
PHP Version: 5.1.2
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2010-01-10 13:02:10] svn@php.net
Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revision&revision=293345
Log: Fixed PHP bug #36172 (subclass serialization of parent private
members).
------------------------------------------------------------------------
[2008-04-16 13:30:37] cweiske@php.net
The docs for __sleep still do not mention anything
------------------------------------------------------------------------
[2006-01-30 15:59:27] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
"Method does not have access to its parent's class private properties.
It is possible to serialize them through SPL interface Serializable."
------------------------------------------------------------------------
[2006-01-27 08:38:53] sniper@php.net
reclassified.
------------------------------------------------------------------------
[2006-01-26 21:35:58] php at justin dot meagerman dot net
Thank you for the workaround. However, the existence of a workaround
does not invalidate the bug. This is clearly not expected behavior.
Moreover, when __sleep methods are not defined, the behaviour is as
expected, as noted below.
If this really is not a bug, then it needs to be documented in the
__sleep documentation page (and this bug's category should be changed to
reflect that).
<?php
class A {
private $a;
public function __construct() {
$this->a = 'aVal';
}
}
class B extends A {
private $b;
public function __construct() {
parent::__construct();
$this->b = 'bVal';
}
}
$serialB = serialize(new B());
print_r(unserialize($serialB));
?>
outputs:
B Object
(
[b:private] => bVal
[a:private] => aVal
)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/36172
--
Edit this bug report at http://bugs.php.net/?id=36172&edit=1
Thread (2 messages)