treat true as empty string, skip false in xml format
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 19 Jan 2014 09:42:47 +0000 (10:42 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sun, 19 Jan 2014 09:42:47 +0000 (10:42 +0100)
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

index e707eb4..764e609 100644 (file)
@@ -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] );
+                                       }
                                }
                        }