From: csnyder at fcny dot org
Operating system: Linux
PHP version: 5.2.9
PHP Bug Type: Scripting Engine problem
Bug description: Unserialize converts string to integer in case of numeric
properties
Description:
------------
When unserializing a string like
O:8:"stdClass":3:{s:5:"22387";s:1:"a";s:5:"22386";s:1:"a";s:5:"22368";s:1:"a";},
the resulting object will have integers as property names instead of
strings.
This may be regression of #43614, marked fixed in CVS but that was a year
ago.
Reproduce code:
---------------
<?php
// an object with some numeric keys
$keys = array( "1", "2", "3" );
foreach( $keys AS $key ) {
$obj->{$key} = 'a';
}
var_dump( $obj );
$s = serialize( $obj );
$u = unserialize( $s );
var_dump( $u );
?>
Expected result:
----------------
object(stdClass)#1 (3) {
["1"]=>
string(1) "a"
["2"]=>
string(1) "a"
["3"]=>
string(1) "a"
}
object(stdClass)#2 (3) {
["1"]=>
string(1) "a"
["2"]=>
string(1) "a"
["3"]=>
string(1) "a"
}
Actual result:
--------------
object(stdClass)#1 (3) {
["1"]=>
string(1) "a"
["2"]=>
string(1) "a"
["3"]=>
string(1) "a"
}
object(stdClass)#2 (3) {
[1]=>
string(1) "a"
[2]=>
string(1) "a"
[3]=>
string(1) "a"
}
--
Edit bug report at http://bugs.php.net/?id=48171&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48171&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48171&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48171&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48171&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48171&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48171&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48171&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48171&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48171&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48171&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48171&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48171&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48171&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48171&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48171&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48171&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48171&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48171&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48171&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48171&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48171&r=mysqlcfg