From: thomas at raptr dot com
Operating system: FC8
PHP version: 5.2.6
PHP Bug Type: Streams related
Bug description: changed serialization behaviour
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
--
Edit bug report at http://bugs.php.net/?id=45672&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45672&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45672&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45672&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45672&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45672&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45672&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45672&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45672&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45672&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45672&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45672&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45672&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45672&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45672&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45672&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45672&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45672&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45672&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45672&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45672&r=mysqlcfg