ID:               36693
 Updated by:       [EMAIL PROTECTED]
 Reported By:      iain at iaindooley dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Class/Object related
 Operating System: FreeBSD 6.0
 PHP Version:      5.1.2
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Cannot reproduce.


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

[2006-03-11 03:21:18] iain at iaindooley dot com

Description:
------------
a call to get_class_vars from within the class includes private
members, but get_object_vars does not

this bug report:

http://bugs.php.net/bug.php?id=27798&edit=2

says that this was fixed about a year ago.

Reproduce code:
---------------
<?
class SomeClass implements Serializable
{
    private $member;
    public $another;

    function SomeClass()
    {
        $this->member = 'member value';
        $this->another = 'another value';
    }

    public function serialize()
    {
        print_r(get_class_vars(__CLASS__));
        print_r(get_object_vars($this));
    }

    public function unserialize($serialized)
    {
    }
}

class AnotherClass extends SomeClass
{
    function AnotherClass()
    {
        $this->SomeClass();
    }
}

$obj = new AnotherClass();
serialize($obj);
?>


Expected result:
----------------
i would expect to see:

Array
(
    [member] =>
    [another] =>
)
Array
(
    [member] => member value
    [another] => another value
)


Actual result:
--------------
Array
(
    [member] =>
    [another] =>
)
Array
(
    [another] => another value
)

i have been able to work around this problem by doing:
public function serialize()
{
    $serialized = array();

    foreach(array_keys(get_class_vars(__CLASS__)) as $key)
        eval('$serialized[\''.$key.'\'] =        
                                       $this->'.$key.';');
    $this->serializeMore($serialized);
    return serialize($serialized);
}


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


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

Reply via email to