Bug #71838 [Opn]: Deserializing serialized SPLObjectStorage-Object can't access properties in PHP
| From: | andreas at heigl dot org | Date: | Wed, 16 Mar 2016 15:22:36 +0000 |
| Subject: | Bug #71838 [Opn]: Deserializing serialized SPLObjectStorage-Object can't access properties in PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199866@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71838&edit=1
ID: 71838
User updated by: andreas at heigl dot org
Reported by: andreas at heigl dot org
-Summary: 39
+Summary: Deserializing serialized SPLObjectStorage-Object
can't access properties in PHP
Status: Open
Type: Bug
Package: SPL related
Operating System: 3v4l.org
PHP Version: 7.0.4
Block user comment: N
Private report: N
New Comment:
-
Previous Comments:
------------------------------------------------------------------------
[2016-03-16 15:21:11] andreas at heigl dot org
Removing the "extends SPLObjectStorage" fixes the issue as can be seen at https://3v4l.org/SjBmY
------------------------------------------------------------------------
[2016-03-16 15:16:10] andreas at heigl dot org
Description:
------------
It seems that with PHP7 (and HHVM) deserializing a serialized SPLObjectStorage-Object results in an
Object that can not access the properties any more. The properties seem to be there (somehow) as a
"var_Dump($obj)" shows them, but methods from inside the newly created object can't
access those values any more.
I've created a test-script at https://3v4l.org/LCmI2 to
illustrate the case.
Am I missing something? I could not find a reference to this behaviour but I might just not have
searched for the right terms...
Test script:
---------------
<?php
class A extends SplObjectStorage
{
protected $a = null;
public function __construct()
{
$this->a = '123';
}
public function getA()
{
return $this->a;
}
}
$serialized = serialize(new A());
$obj = unserialize($serialized);
$reader = function & ($object, $property) {
$value = & \Closure::bind(function & () use ($property) {
return $this->$property;
}, $object, $object)->__invoke();
return $value;
};
$test3 = & $reader($obj, 'a');
echo "Result from Getter\n";
var_dump($obj->getA());
echo "Result from Reflection\n";
var_Dump($test3);
echo "This is the deserialized Object\n";
var_Dump($obj);
Expected result:
----------------
I'd expect the same output in PHP7 as in PHP5.6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71838&edit=1