r46766 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46765‎ | r46766 | r46767 >
Date:16:25, 3 February 2009
Author:catrope
Status:ok
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatXml.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatXml.php
@@ -106,14 +106,6 @@
107107 if (is_string($subElemValue) && $this->mDoubleQuote)
108108 $subElemValue = $this->doubleQuote($subElemValue);
109109
110 - // Replace spaces with underscores
111 - $newSubElemId = str_replace(' ', '_', $subElemId);
112 - if($newSubElemId != $subElemId) {
113 - $elemValue[$newSubElemId] = $subElemValue;
114 - unset($elemValue[$subElemId]);
115 - $subElemId = $newSubElemId;
116 - }
117 -
118110 if (gettype($subElemId) === 'integer') {
119111 $indElements[] = $subElemValue;
120112 unset ($elemValue[$subElemId]);
Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -140,8 +140,7 @@
141141 $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
142142 if( isset( $prop['metadata'] ) ) {
143143 $metadata = $file->getMetadata();
144 - $vals['metadata'] = $metadata ? unserialize( $metadata ) : null;
145 - $result->setIndexedTagName_recursive( $vals['metadata'], 'meta' );
 144+ $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
146145 }
147146 if( isset( $prop['mime'] ) )
148147 $vals['mime'] = $file->getMimeType();
@@ -154,6 +153,22 @@
155154
156155 return $vals;
157156 }
 157+
 158+ public static function processMetaData($metadata, $result)
 159+ {
 160+ $retval = array();
 161+ foreach($metadata as $key => $value)
 162+ {
 163+ $r = array('name' => $key);
 164+ if(is_array($value))
 165+ $r['value'] = self::processMetaData($value, $result);
 166+ else
 167+ $r['value'] = $value;
 168+ $retval[] = $r;
 169+ }
 170+ $result->setIndexedTagName($retval, 'metadata');
 171+ return $retval;
 172+ }
158173
159174 public function getAllowedParams() {
160175 return array (
Index: trunk/phase3/RELEASE-NOTES
@@ -156,6 +156,7 @@
157157 * (bug 17239) Added prop=displaytitle to action=parse
158158 * (bug 17317) Added watch parameter to action=protect
159159 * (bug 17007) Added export and exportnowrap parameters to action=query
 160+* (bug 17326) BREAKING CHANGE: Changed output format for iiprop=metadata
160161
161162 === Languages updated in 1.15 ===
162163

Status & tagging log