From:             denis at edistar dot com
Operating system: Linux
PHP version:      5.2.1RC4
PHP Bug Type:     Session related
Bug description:  __sleep should return private parent members

Description:
------------
I have two classes: 
- one parent with a private property
- one child that extends the parent

When i serialize the child property I get the following 
error:

Notice: serialize(): "privateProperty" returned as member 
variable from __sleep() but does not exist in test.php on 
line 30

I already know of serializable interface. But the problem 
still persist also using this interface... 
If I define a serialize method in the parent class, 
get_object_vars and reflection api do not return the 
privateProperty value... they continue to think we are 
into the scope of the child class (when we are instead 
into the parent class).





Reproduce code:
---------------
<?

class P {

        private $privateProperty;

        public function __construct() {
                $this->privateProperty = "myValue";
        }


        public function __sleep() {

                return array('privateProperty');
        }

}

class D extends P {

        public function __construct() {
                parent::__construct();
        }

}


$obj = new D();

$s = serialize($obj);
echo $s;


?>


Expected result:
----------------
I expect no warning should be raised and the echo should 
print this:

O:1:"D":1:{s:15:"privateProperty";s:7:"myValue";}



Actual result:
--------------
Notice: serialize(): "privateProperty" returned as member 
variable from __sleep() but does not exist in test.php on 
line 30
O:1:"D":1:{s:15:"privateProperty";N;}

-- 
Edit bug report at http://bugs.php.net/?id=40412&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40412&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40412&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40412&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40412&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40412&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40412&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40412&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40412&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40412&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40412&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40412&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40412&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40412&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40412&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40412&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40412&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40412&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40412&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40412&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40412&r=mysqlcfg

Reply via email to