ID:               44888
 User updated by:  phpbugs at delinked dot net
 Reported By:      phpbugs at delinked dot net
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Linux (Gentoo) and FreeBSD
-PHP Version:      5.2.6
+PHP Version:      5.2.5
 New Comment:

To add to dbushea's comment, I've been able to produce this using the
Gentoo portage version (5.2.5p1), FreeBSD port version (5.2.5
w/Suhosin), and 5.2.5 manually compiled on Gentoo and Fedora.


Previous Comments:
------------------------------------------------------------------------

[2008-05-02 04:20:05] dbushea at gmail dot com

Unable to reproduce on:
Windows XP 32/64bit
Windows 2003 Web/Standard/Enterprise
Windows 2000 Server

Results are exactly the same from each OS:
array(1) {
  ["words"]=>
  array(1) {
    [123]=>
    string(3) "foo"
  }
}
string(3) "foo"
string(3) "foo"
string(3) "foo"
111111

------------------------------------------------------------------------

[2008-05-02 04:00:50] phpbugs at delinked dot net

Description:
------------
If an array is unserialized where a numerical key is represented as a
string (s:3:"123"), the key and its value become inaccessible via direct
access ($array[123]) as well as via isset, is_*, array_key_exists,
var_dump, etc. The key and value are accessible via var_dump of the
whole array, or via foreach.

Reproduce code:
---------------
<?php
$bob = unserialize('a:1:{s:5:"words";a:1:{s:3:"123";s:3:"foo";}}');
echo var_dump($bob);
echo var_dump($bob['words']['123']);
$id1 = '123';
echo var_dump($bob['words'][$id1]);
$id2 = 123;
echo var_dump($bob['words'][$id2]);
echo
0+isset($bob['words']['123']),0+isset($bob['words'][$id1]),0+isset($bob['words'][$id2]);
echo
0+array_key_exists('123',$bob['words']),0+array_key_exists($id1,$bob['words']),0+array_key_exists($id2,$bob['words']);
?>

Expected result:
----------------
array(1) {
  ["words"]=>
  array(1) {
    [123]=>
    string(3) "foo"
  }
}
string(3) "foo"
string(3) "foo"
string(3) "foo"
111111

- OR -

array(1) {
  ["words"]=>
  array(1) {
    ["123"]=>
    string(3) "foo"
  }
}
string(3) "foo"
string(3) "foo"
string(3) "foo"
111111

Actual result:
--------------
array(1) {
  ["words"]=>
  array(1) {
    ["123"]=>
    string(3) "foo"
  }
}
NULL
NULL
NULL
000000


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44888&edit=1

Reply via email to