From c9873a92306b5f62476b8edc11782755a8cebdcd Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 4 Nov 2011 01:31:15 +0000 Subject: [PATCH] Partial revert of r101912 -- restores r99315 'includexmlnamespace' parameter for API, but keeps the logic to keep that from clobbering alternate XML output formats with their own namespaces. --- includes/api/ApiFormatXml.php | 19 +++++++++++++------ includes/filerepo/File.php | 3 +++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 6e59961438..6931eb592b 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,18 +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 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 ); + if ( $this->mIncludeNamespace ) { + // 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 ); + } else { + $data = $this->getResultData(); + } $this->printText( self::recXmlPrint( $this->mRootElemName, @@ -208,6 +213,7 @@ class ApiFormatXml extends ApiFormatBase { return array( 'xmldoublequote' => false, 'xslt' => null, + 'includexmlnamespace' => false, ); } @@ -215,6 +221,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' ); } diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index e78eca4104..78a618d91e 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -1476,15 +1476,18 @@ abstract class File { # Get size in bytes $info['size'] = filesize( $path ); + wfDebug("XXX $path $ext {$info[file-mime]} {$info[mime]} {$info[major_mime]} {$info[minor_mime]} {$info[media_type]} {$info[size]}\n"); # Height, width and metadata $handler = MediaHandler::getHandler( $info['mime'] ); if ( $handler ) { $tempImage = (object)array(); $info['metadata'] = $handler->getMetadata( $tempImage, $path ); $gis = $handler->getImageSize( $tempImage, $path, $info['metadata'] ); + wfDebug("XXX $path has handler, metadata is {$info[metadata]}\n"); } else { $gis = false; $info['metadata'] = ''; + wfDebug("XXX $path no handler, no metadata\n"); } $info['sha1'] = self::sha1Base36( $path ); -- 2.20.1