Bug #71838 [NEW]: Deserializing serialized SPLObjectStorage-Object can't access properties in PHP

From: Date: Wed, 16 Mar 2016 15:16:13 +0000
Subject: Bug #71838 [NEW]: Deserializing serialized SPLObjectStorage-Object can't access properties in PHP
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199864@lists.php.net to get a copy of this message
From: andreas at heigl dot org Operating system: 3v4l.org PHP version: 7.0.4 Package: SPL related Bug Type: Bug Bug description:Deserializing serialized SPLObjectStorage-Object can't access properties in PHP 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 bug report at https://bugs.php.net/bug.php?id=71838&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71838&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71838&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71838&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71838&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71838&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71838&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71838&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71838&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71838&r=support Expected behavior: https://bugs.php.net/fix.php?id=71838&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71838&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71838&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71838&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71838&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71838&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71838&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71838&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71838&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71838&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71838&r=mysqlcfg

« previous php.bugs (#199864) next »