|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-31 23:09 UTC] jani@php.net
[2008-07-31 23:50 UTC] thomas at raptr dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 05:00:01 2025 UTC |
Description: ------------ 5.2.6's unserialize() has a different behaviour than 5.2.5's. In 5.2.6, unserialize() turns integer-based key in a stdClass into an key of integer type. In 5.2.5, the key left an string type. Reproduce code: --------------- <?php class A { public function execute() { $a = new stdClass(); $a->{self::B} = "c"; echo "Before:\n"; var_dump($a); $str = serialize($a); $a = unserialize($str); echo "After:\n"; var_dump($a); echo $a->{self::B} . "\n"; } const B = "1"; } $a = new A(); $a->execute(); ?> Expected result: ---------------- Before: object(stdClass)#2 (1) { ["1"]=> string(1) "c" } After: object(stdClass)#3 (1) { ["1"]=> string(1) "c" } c Actual result: -------------- Before: object(stdClass)#2 (1) { ["1"]=> string(1) "c" } After: object(stdClass)#3 (1) { [1]=> string(1) "c" } Notice: Undefined property: stdClass::$1 in /tmp/a.php on line 17 Call Stack: 0.0010 50016 1. {main}() /tmp/a.php:0 0.0386 50240 2. A->execute() /tmp/a.php:25