From e965a1459de80f8f5017a8199b3ab35782a67b3e Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 19 Jan 2014 10:42:47 +0100 Subject: [PATCH] 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 --- includes/api/ApiFormatXml.php | 7 +++++++ 1 file changed, 7 insertions(+) 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] ); + } } } -- 2.20.1