Skip to content

Commit

Permalink
Fix a bug in Xml::fromArray()
Browse files Browse the repository at this point in the history
When creating from an array with elements like this: `[ "a" => [ 0 ] ]` or `[ "a" => [ '0' ] ]` it fails and produces XML like this `<a/>` instant of `<a>0</a>`.

The problem is that in PHP `empty('0')` is true, so an exception to this case is needed.
  • Loading branch information
domingues committed Dec 13, 2016
1 parent cdef76e commit 4d77cb0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Xml.php
Expand Up @@ -312,7 +312,7 @@ protected static function _createChild($data) {
$childNS = $value['xmlns:'];
unset($value['xmlns:']);
}
} elseif (!empty($value) || $value === 0) {
} elseif (!empty($value) || $value === 0 || $value === '0') {
$childValue = (string)$value;
}

Expand Down

0 comments on commit 4d77cb0

Please sign in to comment.