Home » XML » XML_Serializer » Bug #785
Some data types being evaluated incorrectly
Details
| Submitted | 2004-02-18 11:37 UTC |
|---|---|
| From | chris at accurate dot com |
| Status | Bogus |
| Package | XML_Serializer |
| PHP Version | 4.3.4 |
| OS | WIN32 XP |
| Roadmaps | (Not assigned) |
Comments
[2004-02-18 11:37 UTC] chris at accurate dot com
Description:
------------
If a node value of zero(0) is passed to createTagFromArray it is evaluated as an empty string and an empty node is returned rather than a node containing the value zero (0).
This can be fixed by moving/correcting the check to see if the value is an empty string:-
if (is_scalar($tag["content"])) {
if ((string)$tag["content"] === '') {
$tag["content"] = '';
}
// blah...
}
(Not sure of the line number, sorry, I've edited the page!)
Reproduce code:
---------------
$tag = array('qname' => 'foo', 'content' => 0);
$serializer = new XML_Serializer();
$bar = $serializer->_createXMLTag($tag);
Expected result:
----------------
$bar = '<foo>0</foo>';
Actual result:
--------------
$bar = '<foo />';