php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70959 ArrayObject unserialize does not restore protected fields
Submitted: 2015-11-23 10:37 UTC Modified: -
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: tarasov dot igor at gmail dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 7.0.0RC7 OS: Ubuntu 14.04.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tarasov dot igor at gmail dot com
New email:
PHP Version: OS:

 

 [2015-11-23 10:37 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-23 15:16 UTC] laruence@php.net
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)
 [2015-11-23 15:16 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2015-11-25 02:21 UTC] ab@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=254e70948437b5a412630784e7eb4b2a40147e4c
Log: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
 [2015-11-25 16:01 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f8bf1f33a53d1aaaa1109cb986544635aaa63f66
Log: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
 [2016-07-20 11:35 UTC] davey@php.net
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)
 [2016-07-20 11:35 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f8bf1f33a53d1aaaa1109cb986544635aaa63f66
Log: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 06:01:28 2024 UTC