Bug #66052 [Com]: Serialized value ids are shared between nested serialization operations

From: Date: Fri, 17 Feb 2017 14:03:26 +0000
Subject: Bug #66052 [Com]: Serialized value ids are shared between nested serialization operations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207431@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66052&edit=1 ID: 66052 Comment by: hwold at hwold dot net Reported by: crog at gustavus dot edu Summary: Serialized value ids are shared between nested serialization operations Status: Open Type: Bug Package: *General Issues PHP Version: 5.4.21 Block user comment: N Private report: N New Comment: Still present in PHP 7.1.2. Another test case : https://3v4l.org/BXuv8 Code: ----- <?php class User { public $name = "admin"; } class UserCouple implements Serializable { public $user1; public $user2; public function serialize() { return serialize(array(42, serialize(array($this->user1, $this->user2)))); } public function unserialize($serialized) { list($_, $subSerialized) = unserialize($serialized); list($this->user1, $this->user2) = unserialize($subSerialized); } } $user = new User(); $couple = new UserCouple(); $couple->user1 = $user; $couple->user2 = $user; var_dump(unserialize(serialize($couple))); Expected result --------------- object(UserCouple)#3 (2) { ["user1"]=> object(User)#4 (1) { ["name"]=> string(5) "admin" } ["user2"]=> object(User)#4 (1) { ["name"]=> string(5) "admin" } } Actual result ------------- object(UserCouple)#3 (2) { ["user1"]=> object(User)#4 (1) { ["name"]=> string(5) "admin" } ["user2"]=> int(42) } Previous Comments: ------------------------------------------------------------------------ [2017-01-07 23:07:06] php at laszlokorte dot de I guess I came across the same issue. The following gist reproduces it even in php7.0.14: https://gist.github.com/laszlokorte/3948f40873346cc1fd9b8c11ab06ae04 ------------------------------------------------------------------------ [2017-01-07 22:15:21] nikic@php.net Related To: Bug #67363 ------------------------------------------------------------------------ [2017-01-01 12:32:51] nikic@php.net Related To: Bug #70803 ------------------------------------------------------------------------ [2017-01-01 12:30:20] nikic@php.net Note that the issue in the last comment is due to bug #66085, which is resolved in PHP 7. Of course this still leaves the overall problem. ------------------------------------------------------------------------ [2017-01-01 12:27:58] nikic@php.net Related To: Bug #73253 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=66052 -- Edit this bug report at https://bugs.php.net/bug.php?id=66052&edit=1

« previous php.bugs (#207431) next »