php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31541 unserializing a PHP 4.2.2 array with "-1" as a key
Submitted: 2005-01-13 17:44 UTC Modified: 2005-01-14 05:26 UTC
From: mop at globalpark dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mop at globalpark dot de
New email:
PHP Version: OS:

 

 [2005-01-13 17:44 UTC] 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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-14 05:26 UTC] sniper@php.net
This was bug that is fixed now:

http://bugs.php.net/bug.php?id=21918&edit=1

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 19:01:32 2024 UTC