Req #71995 [NEW]: Returning the same var twice from __sleep() produces broken serialized data

From: Date: Fri, 08 Apr 2016 20:05:19 +0000
Subject: Req #71995 [NEW]: Returning the same var twice from __sleep() produces broken serialized data
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200444@lists.php.net to get a copy of this message
From: jsnell at e-normous dot com Operating system: Linux PHP version: 7.0.5 Package: Unknown/Other Function Bug Type: Feature/Change Request Bug description:Returning the same var twice from __sleep() produces broken serialized data 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 bug report at https://bugs.php.net/bug.php?id=71995&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71995&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71995&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71995&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71995&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71995&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71995&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71995&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71995&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71995&r=support Expected behavior: https://bugs.php.net/fix.php?id=71995&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71995&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71995&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71995&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71995&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71995&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71995&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71995&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71995&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71995&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71995&r=mysqlcfg

« previous php.bugs (#200444) next »