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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
16 + 5 = ?
Subscribe to this entry?

 
 [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

Pull Requests

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: Fri Sep 27 23:01:26 2024 UTC