From: hannes at phpug dot ch
Operating system: Debian GNU/Linux
PHP version: 5.0.0RC1
PHP Bug Type: Zend Engine 2 problem
Bug description: unserialize / Array access
Description:
------------
Unserialize works perfectly and produces an array with like
array("0" => "foo"). The same serialized string gets unserialized
differently in PHP4, there it's array(0 => "foo").
I cannot access the content of the PHP5 result, because it seems that my
lookup for "1"(string) gets converted to one for 1 (int). Which fails.
Tested with:
-PHP 4.3.5RC2-dev (cli) (built: Jan 15 2004 16:58:31)
-PHP 5.0.0RC2-dev (cli) (built: Mar 21 2004 17:58:48)
I'm not sure if this is really something that needs to be fixed,
unserialize works correctly, but not as expected.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
$serializedNames = 'a:2:{s:1:"0";s:6:"hubert";s:1:"1";s:5:"waldo";}';
$names = unserialize($serializedNames);
var_export($names); //works, but...
/*
php5:
array (
'0' => 'hubert',
php4:
array (
0 => 'hubert',
..
print($names["1"]); // php5: doesn't work. php4: works;
print($names[1]); // php5: doesn't work php4: works;
?>
Expected result:
----------------
array (
0 => 'hubert',
1 => 'waldo',
)waldowaldo
Actual result:
--------------
array (
'0' => 'hubert',
'1' => 'waldo',
)
PHP Notice: Undefined index: 1 in ....
--
Edit bug report at http://bugs.php.net/?id=27712&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27712&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27712&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27712&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27712&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27712&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27712&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27712&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27712&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27712&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27712&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27712&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27712&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27712&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27712&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27712&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27712&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27712&r=float