Bug #70959 [Opn->Csd]: ArrayObject unserialize does not restore protected fields

From: Date: Mon, 23 Nov 2015 15:16:37 +0000
Subject: Bug #70959 [Opn->Csd]: ArrayObject unserialize does not restore protected fields
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197380@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70959&edit=1

 ID:                 70959
 Updated by:         laruence@php.net
 Reported by:        tarasov dot igor at gmail dot com
 Summary:            ArrayObject unserialize does not restore protected
                     fields
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Ubuntu 14.04.3
 PHP Version:        7.0.0RC7
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7e9f416218165f7329358e0432c6373d664c5ed7
Log: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)


Previous Comments:
------------------------------------------------------------------------
[2015-11-23 10:37:57] tarasov dot igor at gmail dot com

Description:
------------
If you unserialize ArrayObject extended object, protected properties are not getting restored. In
all previous php versions behavior was different, and I was unable to find any indications in docs
that this has changed.

Test script:
---------------
class testObject extends ArrayObject {
    protected $test;

    public function getTest() {
        return $this->test;
    }

    public function setTest($test) {
        $this->test = $test;
    }
}

$obj = new testObject();
$obj->setTest('test');
var_dump($obj->getTest());
$obj2 = unserialize(serialize($obj));
var_dump($obj2->getTest());

Expected result:
----------------
string(4) "test"
string(4) "test"

Actual result:
--------------
string(4) "test"
NULL


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



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


Thread (2 messages)

« previous php.bugs (#197380) next »