From: umherirrender Date: Sun, 19 Jan 2014 09:42:47 +0000 (+0100) Subject: treat true as empty string, skip false in xml format X-Git-Tag: 1.31.0-rc.0~17078^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=e965a1459de80f8f5017a8199b3ab35782a67b3e;p=lhc%2Fweb%2Fwiklou.git treat true as empty string, skip false in xml format The xml format gives a empty attribute to indicate a true, for example top="" or anon="". The new meta=filerepoinfo module gives natural booleans to the xml formatter, which than will converted to strings, that gives a empty attribute for false and a attribute with the value "1" for true attributes. Change this behaviour in xml formatter to allow the natural booleans on the other formats like json, which support that better than xml. Bug: 59953 Change-Id: Iedf43aae2e624e8e15c9cf102d24b8365110164a --- diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index e707eb4e28..764e609005 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -156,6 +156,13 @@ class ApiFormatXml extends ApiFormatBase { } elseif ( is_array( $subElemValue ) ) { $subElements[$subElemId] = $subElemValue; unset( $elemValue[$subElemId] ); + } elseif ( is_bool( $subElemValue ) ) { + // treat true as empty string, skip false in xml format + if ( $subElemValue === true ) { + $subElemValue = ''; + } else { + unset( $elemValue[$subElemId] ); + } } }