Bug #70959 [NEW]: ArrayObject unserialize does not restore protected fields
From: tarasov dot igor at gmail dot com
Operating system: Ubuntu 14.04.3
PHP version: 7.0.0RC7
Package: Class/Object related
Bug Type: Bug
Bug description:ArrayObject unserialize does not restore protected fields
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 bug report at https://bugs.php.net/bug.php?id=70959&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70959&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70959&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70959&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70959&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70959&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70959&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70959&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70959&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70959&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70959&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70959&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70959&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70959&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70959&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70959&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70959&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70959&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70959&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70959&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70959&r=mysqlcfg
Thread (2 messages)
- tarasov dot igor at gmail dot com