Req #71995 [Opn->Ver]: Returning the same var twice from __sleep() produces broken serialized data
| From: | krakjoe@php.net | Date: | Sat, 09 Apr 2016 09:35:16 +0000 |
| Subject: | Req #71995 [Opn->Ver]: Returning the same var twice from __sleep() produces broken serialized data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200449@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71995&edit=1
ID: 71995
Updated by: krakjoe@php.net
Reported by: jsnell at e-normous dot com
Summary: Returning the same var twice from __sleep() produces
broken serialized data
-Status: Open
+Status: Verified
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: Linux
PHP Version: 7.0.5
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2016-04-08 20:05:15] jsnell at e-normous dot com
Description:
------------
If the same member variable is returned twice from __sleep() and that member variable is a
reference, the serialized output errors when unserialized. This "worked" before PHP7 and
the error during unserialization appears in PHP 7.0.3 and later.
Test script:
---------------
<?php
class C { }
class A { public $b; function __construct() { $this->b = new C(); } function __sleep() { return
array("b", "b"); } }
$a = new A();
var_dump(unserialize(serialize($a)));
Expected result:
----------------
Notice: member variable "b" returned from __sleep() multiple times
or alternately, silently ignore the duplication.
Actual result:
--------------
Notice: unserialize(): Error at offset 43 of 44 bytes in /in/0FNkge on line 6
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71995&edit=1