From: Roan Kattouw Date: Tue, 3 Feb 2009 16:25:50 +0000 (+0000) Subject: * API: (bug 17326) BREAKING CHANGE: Changing output format for prop=imageinfo&iiprop... X-Git-Tag: 1.31.0-rc.0~43058 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=bb81750f27f5c484b89a8d66e1029c56882cba81;p=lhc%2Fweb%2Fwiklou.git * API: (bug 17326) BREAKING CHANGE: Changing output format for prop=imageinfo&iiprop=metadata to something based on name/value pairs. This means we don't use parts of the metadata in attributes anymore, something that caused invalid XML to be output. For more info on the exact format, see the mediawiki-api mailing list * Removed the spaces-to-underscores hack in the XML formatter --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index afc44af5c3..94738fff32 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -156,6 +156,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 17239) Added prop=displaytitle to action=parse * (bug 17317) Added watch parameter to action=protect * (bug 17007) Added export and exportnowrap parameters to action=query +* (bug 17326) BREAKING CHANGE: Changed output format for iiprop=metadata === Languages updated in 1.15 === diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 5004f1acab..81bcfa7318 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -106,14 +106,6 @@ class ApiFormatXml extends ApiFormatBase { if (is_string($subElemValue) && $this->mDoubleQuote) $subElemValue = $this->doubleQuote($subElemValue); - // Replace spaces with underscores - $newSubElemId = str_replace(' ', '_', $subElemId); - if($newSubElemId != $subElemId) { - $elemValue[$newSubElemId] = $subElemValue; - unset($elemValue[$subElemId]); - $subElemId = $newSubElemId; - } - if (gettype($subElemId) === 'integer') { $indElements[] = $subElemValue; unset ($elemValue[$subElemId]); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 0924be6a85..03edc355cf 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -140,8 +140,7 @@ class ApiQueryImageInfo extends ApiQueryBase { $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 ); if( isset( $prop['metadata'] ) ) { $metadata = $file->getMetadata(); - $vals['metadata'] = $metadata ? unserialize( $metadata ) : null; - $result->setIndexedTagName_recursive( $vals['metadata'], 'meta' ); + $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null; } if( isset( $prop['mime'] ) ) $vals['mime'] = $file->getMimeType(); @@ -154,6 +153,22 @@ class ApiQueryImageInfo extends ApiQueryBase { return $vals; } + + public static function processMetaData($metadata, $result) + { + $retval = array(); + foreach($metadata as $key => $value) + { + $r = array('name' => $key); + if(is_array($value)) + $r['value'] = self::processMetaData($value, $result); + else + $r['value'] = $value; + $retval[] = $r; + } + $result->setIndexedTagName($retval, 'metadata'); + return $retval; + } public function getAllowedParams() { return array (