Home » XML » XML_Serializer » Bug #1846
unserialization bug with empty arrays
Details
| Submitted | 2004-07-11 18:01 UTC |
|---|---|
| From | apinstein at showcaseRE dot com |
| Assigned | schst |
| Status | Closed |
| Package | XML_Serializer |
| PHP Version | 4.3.6 |
| OS | mac os x / 10.3.4 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-11 18:01 UTC] apinstein at showcaseRE dot com
Description:
------------
I am using 0.10 of XML_Serializer (and XML_Unserializer)
to serialize PHP objects into a database.
I found a small "warning" bug.... if you serialize an
array which is EMPTY, it gets transformed into valid
XML:
<autopage_options _class="autopage_options"
_type="object">
<version _type="string">1.0</version>
<options _type="array" />
</autopage_options>
However, upon unserialization, a php-notice error:
Notice: Undefined index: children in /usr/local/php/lib/
php/XML/Unserializer.php on line 419
It seems to be fixed by patching like so:
/*
* unserialize an array
*/
case "array":
if ($data !== '') {
$value["children"][$this-
>options["contentName"]] = $data;
}
// add IF to only do assign if the value
exists
if (isset($value["children"]))
$value["value"] =
$value["children"];
break;
Expected result:
----------------
I would expect that you could serialize / unserialize an
empty array safely and without warning / error.