#31541 [Opn->Bgs]: unserializing a PHP 4.2.2 array with "-1" as a key
| From: | sniper@php.net | Date: | Fri, 14 Jan 2005 04:26:11 +0000 |
| Subject: | #31541 [Opn->Bgs]: unserializing a PHP 4.2.2 array with "-1" as a key | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-72103@lists.php.net to get a copy of this message | ||
ID: 31541
Updated by: sniper@php.net
Reported By: mop at globalpark dot de
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Linux
PHP Version: 5.0.3
New Comment:
This was bug that is fixed now:
http://bugs.php.net/bug.php?id=21918&edit=1
Previous Comments:
------------------------------------------------------------------------
[2005-01-13 17:44:29] mop at globalpark dot de
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 this bug report at http://bugs.php.net/?id=31541&edit=1