PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » XML » XML_Serializer » Bug #1846

unserialization bug with empty arrays

Details

Submitted2004-07-11 18:01 UTC
Fromapinstein at showcaseRE dot com
Assignedschst
StatusClosed
PackageXML_Serializer
PHP Version4.3.6
OSmac 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.