ID:               27350
 Updated by:       [EMAIL PROTECTED]
 Reported By:      davojan at mail dot ru
-Status:           Open
+Status:           Verified
-Bug Type:         Session related
+Bug Type:         *General Issues
-Operating System: FreeBSD 4.7-RELEASE
+Operating System: *
-PHP Version:      5.0.0b4 (beta4)
+PHP Version:      5CVS-2004-02-23
 New Comment:

This is not session related but serialize/unserialize problem.

Here's better test script:



<?php



class foo 

{

        public    $x = 1;

        protected $y = 2;

        private   $z = 3;



        function __sleep ()

        {

                foreach ($this as $Key => $Value) {

                        $Result[] = $Key;

                }

                return $Result;

        }



}



$foo = new foo();

$bar = unserialize(serialize($foo));



print_r($foo);

print_r($bar);



?>



Output is the same as in the initial report.




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

[2004-02-22 10:57:42] davojan at mail dot ru

Description:
------------
When unserializing after __sleep(), private and protected fields are
duplicated with the public ones with the same name.

Note, that in php5.0.0b2 the example works fine. I think it's because
of "foreach", which:

- in php5b4: gives the plane names of fields;

- in php5b2: there was a string with additional information about scope
("*", for example) and with '\0' delimiters.

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

class foo {

        public    $x = 1;

        protected $y = 2;

        private   $z = 3;

        function __sleep()

        {

                foreach ($this as $Key => $Value) {

                        $Result[] = $Key;

                }

                return $Result;

        }

}

        session_start();

        $_SESSION['foo'] = new foo();

        print_r ($_SESSION['foo']);

        session_write_close();

        session_start();

        print_r ($_SESSION['foo']);

?>

Expected result:
----------------
foo Object

(

    [x] => 1

    [y:protected] => 2

    [z:private] => 3

)

foo Object

(

    [x] => 1

    [y:protected] => 2

    [z:private] => 3

)

Actual result:
--------------
foo Object

(

    [x] => 1

    [y:protected] => 2

    [z:private] => 3

)

foo Object

(

    [x] => 1

    [y:protected] => 2

    [z:private] => 3

    [y] => 

    [z] => 

)


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


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

Reply via email to