* (bug 31878, bug 31542) Fix XML namespace output in API; removed now-unneeded includ...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Nov 2011 23:14:58 +0000 (23:14 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Nov 2011 23:14:58 +0000 (23:14 +0000)
Any existing uses of includexmlnamespace should be ignored and harmless.

If output data already includes a specific default namespace as an xmlns attribute, it is now retained -- so for example the RSD API discovery module outputs the appropriate namespace instead of the generic API one.

Partial revert of r99135 which added the includexmlnamespace parameter as a temporary requirement to get the xmlns attribute included.

Followup to r88007 which added the xmlns originally, but in the wrong order so it overrode existing output data.

includes/api/ApiFormatXml.php

index 814864f..6e59961 100644 (file)
@@ -38,7 +38,6 @@ 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 ) {
@@ -60,18 +59,18 @@ 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();
-               }
+
+               // If the result data already contains an 'xmlns' namespace added
+               // for custom XML output types, it will override the one for the
+               // generic API results.
+               // This allows API output of other XML types like Atom, RSS, RSD.
+               $data = $this->getResultData() + array( 'xmlns' => self::$namespace );
 
                $this->printText(
                        self::recXmlPrint( $this->mRootElemName,
@@ -209,7 +208,6 @@ class ApiFormatXml extends ApiFormatBase {
                return array(
                        'xmldoublequote' => false,
                        'xslt' => null,
-                       'includexmlnamespace' => false,
                );
        }
 
@@ -217,7 +215,6 @@ 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'
                );
        }