#31541 [NEW]: unserializing a PHP 4.2.2 array with "-1" as a key
From: mop at globalpark dot de
Operating system: Linux
PHP version: 5.0.3
PHP Bug Type: Unknown/Other Function
Bug description: unserializing a PHP 4.2.2 array with "-1" as a key
Description:
------------
We have been using PHP 4.2.2 a while ago and saved
serialized data in our database. Since we moved to PHP5 we
had some problems unserializing some of this data. When
"-1" (string) as an array key was used it appeared as a
string in serialized form (PHP 4.2.2). PHP 4.3.10 and PHP
5.0.3 produce a serialized string with an integer. Using
the PHP 4.2.2 generated data with PHP 4.3.10 works as
expected but when we try to access the array using PHP
5.0.3 it doesn't work. That's really annoying.
Reproduce code:
---------------
1. Script
<?php
print serialize(array("-1"=>-1))."\n";
?>
2. Script
<?php
$string='a:1:{s:2:"-1";s:2:"-1";}';
$arr=unserialize($string);
var_dump($arr["-1"]);
var_dump($arr[-1]);
?>
// PHP 4.2.2 and PHP 4.3.10 => OK
// PHP 5.0.3 => both are NULL
Expected result:
----------------
PHP 5.0.3 should return -1 in both cases
Actual result:
--------------
PHP 5.0.3 returns NULL
--
Edit bug report at http://bugs.php.net/?id=31541&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31541&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31541&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31541&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31541&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31541&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31541&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31541&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31541&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31541&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31541&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31541&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31541&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31541&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31541&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31541&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31541&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31541&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31541&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31541&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31541&r=mysqlcfg
Thread (2 messages)
- mop at globalpark dot de