(bug 24781) The API will include an XML namespace if the includexmlnamespace paramete...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 6 Oct 2011 20:11:44 +0000 (20:11 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Thu, 6 Oct 2011 20:11:44 +0000 (20:11 +0000)
Partial revert of r88007, which adds the namespace unconditionally, since it breaks stuff as per the bug discussion.

RELEASE-NOTES-1.18
includes/api/ApiFormatXml.php

index a9df0f9..2bf1051 100644 (file)
@@ -608,6 +608,8 @@ production.
 * (bug 28817) Add reference help page link to API Modules
 * (bug 29935) Improve formatting of examples in ApiParamInfo
 * (bug 29938) list=users&usprop=rights shows rights the user doesn't have
+* (bug 24781) The API will include an XML namespace if the includexmlnamespace
+  parameter is set.
 
 === Languages updated in 1.18 ===
 
index d76224b..06bd9f3 100644 (file)
@@ -38,6 +38,7 @@ class ApiFormatXml extends ApiFormatBase {
        private $mRootElemName = 'api';
        public static $namespace = 'http://www.mediawiki.org/xml/api/';
        private $mDoubleQuote = false;
+       private $mIncludeNamespace = false;
        private $mXslt = null;
 
        public function __construct( $main, $format ) {
@@ -59,15 +60,22 @@ class ApiFormatXml extends ApiFormatBase {
        public function execute() {
                $params = $this->extractRequestParams();
                $this->mDoubleQuote = $params['xmldoublequote'];
+               $this->mIncludeNamespace = $params['includexmlnamespace'];
                $this->mXslt = $params['xslt'];
 
                $this->printText( '<?xml version="1.0"?>' );
                if ( !is_null( $this->mXslt ) ) {
                        $this->addXslt();
                }
+               if ( $this->mIncludeNamespace ) {
+                       $data = array( 'xmlns' => self::$namespace ) + $this->getResultData();
+               } else {
+                       $data = $this->getResultData();
+               }
+               
                $this->printText(
                        self::recXmlPrint( $this->mRootElemName,
-                               array( 'xmlns' => self::$namespace ) + $this->getResultData(),
+                               $data,
                                $this->getIsHtml() ? - 2 : null,
                                $this->mDoubleQuote
                        )
@@ -201,6 +209,7 @@ class ApiFormatXml extends ApiFormatBase {
                return array(
                        'xmldoublequote' => false,
                        'xslt' => null,
+                       'includexmlnamespace' => false,
                );
        }
 
@@ -208,6 +217,7 @@ class ApiFormatXml extends ApiFormatBase {
                return array(
                        'xmldoublequote' => 'If specified, double quotes all attributes and content',
                        'xslt' => 'If specified, adds <xslt> as stylesheet',
+                       'includexmlnamespace' => 'If specified, adds an XML namespace'
                );
        }