ID:               29754
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mytrash at seznam dot cz
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows XP
 PHP Version:      5.0.1
 New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

This report is a duplicate of #26737, which was closed on 21st August
following a patch by Andrey and Curt..


Previous Comments:
------------------------------------------------------------------------

[2004-08-19 13:15:50] mytrash at seznam dot cz

Description:
------------
Hello.

I use PHP session. When I use private or protected members in my class
and don't use magic method __sleep(), PHP serialization will serialize
all members and their values into PHP session correctly.
But when I use the same class and implement magic method __sleep(), PHP
serialization will serialize correctly ONLY public members. Private and
protected members (that I want serialize - I specified them in array
returned from __sleep() function) have NULL value.
In my example's result is string from session file generated by PHP.

T.Zkoumalek

Reproduce code:
---------------
class Test
{
    private   $a = "Variable a";
    protected $b = "Variable b";
    public    $c = "Variable c";
    public    $d = "This need not be saved.";


    // Save only $a, $b, $c.
    function __sleep()
    {
        return Array( "a", "b", "c" );
    }
}

session_start();
$_SESSION[ "test" ] = new Test();

Expected result:
----------------
test|O:4:"Test":3:{s:7:" Test a";s:10:"Variable a";s:4:" *
b";s:10:"Variable b";s:1:"c";s:10:"Variable c";}

Actual result:
--------------
test|O:4:"Test":3:{s:1:"a";N;s:1:"b";N;s:1:"c";s:10:"Variable c";}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29754&edit=1

Reply via email to