Bug #61042 [Com]: unserialize issue
| From: | vigano dot n at clxeurope dot com | Date: | Fri, 10 Feb 2012 12:14:10 +0000 |
| Subject: | Bug #61042 [Com]: unserialize issue | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167381@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61042&edit=1
ID: 61042
Comment by: vigano dot n at clxeurope dot com
Reported by: vigano dot n at clxeurope dot com
Summary: unserialize issue
Status: Duplicate
Type: Bug
Package: Arrays related
Operating System: Linux Centos
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
Anyway the problem affects only unserialized and cast objects.
The following code works properly also with PHP 5.3.9/10:
$arr1 = array("0" => "string");
var_dump(isset($arr1["0"]));
var_dump(isset($arr1[0]));
returning:
bool(true) bool(true)
Previous Comments:
------------------------------------------------------------------------
[2012-02-10 12:01:19] cataphract@php.net
The bug is not in unserialize; the object is correctly unserialized, with the rule that objects only
have string properties correctly enforced (this was not enforced before 5.3.9 though: see bug
#55798). The problem is that these strings are not converted to numbers when casting to an array.
This is a known problem and unfortunately the main opinion seems to be this ought not to be fixed
due to performance issues.
------------------------------------------------------------------------
[2012-02-10 11:47:47] vigano dot n at clxeurope dot com
Description:
------------
It seems that, using PHP 5.3.9/10, an unserialized object is not properly cast to array.
Test script:
---------------
The following code gives different results using PHP 5.3.8 and PHP 5.3.9/10:
$arr = (object)array("value");
$uns = (array)unserialize(serialize($arr));
var_dump($uns);
var_dump(isset($uns[0]));
Expected result:
----------------
Using PHP 5.3.8:
array(1) { [0]=> string(5) "value" } bool(true)
Actual result:
--------------
Using PHP 5.3.9/10:
array(1) { ["0"]=> string(5) "value" } bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61042&edit=1