From abb23bb7b9ae8cb77b0d579b8f054ce3a48d4f2f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 3 Nov 2011 23:14:58 +0000 Subject: [PATCH] * (bug 31878, bug 31542) Fix XML namespace output in API; removed now-unneeded includexmlnamespace parameter. 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 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 814864f412..6e59961438 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -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( '' ); 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 as stylesheet', - 'includexmlnamespace' => 'If specified, adds an XML namespace' ); } -- 2.20.1