Bug #71617 [NEW]: private properties lost when ArrayObject unserialize
| From: | janpoem at gmail dot com | Date: | Wed, 17 Feb 2016 09:35:03 +0000 |
| Subject: | Bug #71617 [NEW]: private properties lost when ArrayObject unserialize | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-199294@lists.php.net to get a copy of this message | ||
From: janpoem at gmail dot com
Operating system: Windows 10
PHP version: 7.0.3
Package: Class/Object related
Bug Type: Bug
Bug description:private properties lost when ArrayObject unserialize
Description:
------------
The private properties in an ArrayObject will lost when unserialize.
Test script:
---------------
<?php
class Test extends ArrayObject
{
private $name = null;
public function __construct(array $input)
{
parent::__construct($input, ArrayObject::ARRAY_AS_PROPS);
// parent::__construct($input, ArrayObject::STD_PROP_LIST);
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getName()
{
return $this->name;
}
}
$test = new Test(['a' => 'a', 'b' => 'b']);
$test->setName('ok');
$ser = serialize($test);
$unSer = unserialize($ser);
var_dump($unSer->getName()); // null
var_dump($unSer);
// php 7.0.3
/**
null
object(Test)[2]
private 'name' => string 'ok' (length=2)
private 'storage' (ArrayObject) =>
array (size=2)
'a' => string 'a' (length=1)
'b' => string 'b' (length=1)
*/
// php 5.6.x
/**
string 'ok' (length=2)
object(Test)[2]
private 'name' => string 'ok' (length=2)
private 'storage' (ArrayObject) =>
array (size=2)
'a' => string 'a' (length=1)
'b' => string 'b' (length=1)
*/
--
Edit bug report at https://bugs.php.net/bug.php?id=71617&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71617&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71617&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71617&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71617&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71617&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71617&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71617&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71617&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71617&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71617&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71617&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71617&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71617&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71617&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71617&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71617&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71617&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71617&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71617&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71617&r=mysqlcfg