From 4d77cb059dfd4db72179dde9d9da8c17dfad2d54 Mon Sep 17 00:00:00 2001 From: domingues Date: Tue, 13 Dec 2016 16:16:12 +0000 Subject: [PATCH] Fix a bug in Xml::fromArray() When creating from an array with elements like this: `[ "a" => [ 0 ] ]` or `[ "a" => [ '0' ] ]` it fails and produces XML like this `` instant of `0`. The problem is that in PHP `empty('0')` is true, so an exception to this case is needed. --- lib/Cake/Utility/Xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 95bb4659e..f27fc1497 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -312,7 +312,7 @@ class Xml { $childNS = $value['xmlns:']; unset($value['xmlns:']); } - } elseif (!empty($value) || $value === 0) { + } elseif (!empty($value) || $value === 0 || $value === '0') { $childValue = (string)$value; }