Home » XML » XML_Serializer » Bug #5086
Class references sometimes missed with unserialize
Details
| Request #5086 | Class references sometimes missed with unserialize |
|---|---|
| Submitted | 2005-08-14 01:40 UTC |
| From | walter_tom at hotmail dot com |
| Status | Wont fix |
| Package | XML_Serializer |
| PHP Version | 4.4.1 |
| OS | Any |
| Roadmaps | (Not assigned) |
Comments
[2005-08-14 01:40 UTC] walter_tom at hotmail dot com
Description:
------------
XML_Unserializer 0.16.0
If a tag does not have attributes, then the class is not
created, even if tagAsClass is set and complexType is
set to object.
I believe the error is around line 392 of
Unserializer.php:
if ($this->options['parseAttributes'] == true &&
(count($attribs) > 0)) {
$val['children'] = array();
$val['type'] = $this->options['complexType'];
$val['class'] = $element;
As you can see, there is an if statement meaning that
$val['type'] and $val['class'] are not set if the
element has no attributes.
[2005-08-15 07:11 UTC] walter_tom at hotmail dot com
Fair enough.
Attributes can be optional though. As it stands, if an optional attribute is not defined, the object won't be created. This presents a problem for any code that references the object, since it has to take into account whether it is actually an object or a string.
But yeah, no bug, I'm resubmitting this as a feature request.