From 504d37d6fcd29fc1535bbd9de8f08d868cdcb4f4 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Thu, 6 Oct 2011 20:11:44 +0000 Subject: [PATCH] (bug 24781) The API will include an XML namespace if the includexmlnamespace parameter is set. Partial revert of r88007, which adds the namespace unconditionally, since it breaks stuff as per the bug discussion. --- RELEASE-NOTES-1.18 | 2 ++ includes/api/ApiFormatXml.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.18 b/RELEASE-NOTES-1.18 index a9df0f9a81..2bf1051b56 100644 --- a/RELEASE-NOTES-1.18 +++ b/RELEASE-NOTES-1.18 @@ -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 === diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index d76224b92e..06bd9f3362 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -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( '' ); 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 as stylesheet', + 'includexmlnamespace' => 'If specified, adds an XML namespace' ); } -- 2.20.1