r74768 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74767‎ | r74768 | r74769 >
Date:04:34, 14 October 2010
Author:neilk
Status:resolved (Comments)
Tags:
Comment:
followup to comments on r74539 and r74536
Modified paths:
  • /branches/uploadwizard/extensions/UploadWizard/ApiQueryStashImageInfo.php (modified) (history)
  • /branches/uploadwizard/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: branches/uploadwizard/phase3/includes/api/ApiQueryImageInfo.php
@@ -366,11 +366,13 @@
367367 );
368368 }
369369
 370+
370371 /**
371 - * This is broken out from getParamDescription, since some subclasses of this module use identical property parameters.
372 - * @return {Array} parameter description
 372+ * Return the API documentation for the parameters.
 373+ * @return {Array} parameter documentation.
373374 */
374 - public function getPropParamDescription() {
 375+ public function getParamDescription() {
 376+ $p = $this->getModulePrefix();
375377 return array(
376378 'prop' => array(
377379 'What image information to get:',
@@ -387,25 +389,15 @@
388390 ' metadata - Lists EXIF metadata for the version of the image',
389391 ' archivename - Adds the file name of the archive version for non-latest versions',
390392 ' bitdepth - Adds the bit depth of the version',
391 - )
392 - );
393 - }
394 -
395 - /**
396 - * Return the API documentation for the parameters.
397 - * @return {Array} parameter documentation.
398 - */
399 - public function getParamDescription() {
400 - $p = $this->getModulePrefix();
401 - $description = array(
 393+ ),
402394 'urlwidth' => array( "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
403395 'Only the current version of the image can be scaled' ),
404396 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth",
405397 'limit' => 'How many image revisions to return',
406398 'start' => 'Timestamp to start listing from',
407 - 'end' => 'Timestamp to stop listing at'
 399+ 'end' => 'Timestamp to stop listing at',
 400+ 'continue' => 'If the query response includes a continue value, use it here to get another page of results'
408401 );
409 - return array_merge( $description, $this->getPropParamDescription() );
410402 }
411403
412404 public function getDescription() {
Index: branches/uploadwizard/extensions/UploadWizard/ApiQueryStashImageInfo.php
@@ -33,10 +33,7 @@
3434
3535 public function execute() {
3636 $params = $this->extractRequestParams();
37 - $modulePrefix = $this->getModulePrefix;
38 - if ( is_null( $params['sessionkey'] ) ) {
39 - $this->dieUsageMsg( array( 'missingparam', 'sessionkey' ) );
40 - }
 37+ $modulePrefix = $this->getModulePrefix();
4138
4239 $prop = array_flip( $params['prop'] );
4340
@@ -50,13 +47,8 @@
5148 foreach ( $params['sessionkey'] as $sessionkey ) {
5249 $file = $stash->getFile( $sessionkey );
5350 $imageInfo = self::getInfo( $file, $prop, $result, $scale );
54 - $result->setIndexedTagName( $imageInfo, $modulePrefix );
55 - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo );
56 - /* TODO overflow of continue */
57 - if ( !$fit ) {
58 - $this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->fa_name ) );
59 - break;
60 - }
 51+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $modulePrefix );
 52+ $result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo );
6153 }
6254
6355 } catch ( SessionStashNotAvailableException $e ) {
@@ -69,7 +61,24 @@
7062
7163 }
7264
 65+ /**
 66+ * Returns all valid parameters to siiprop
 67+ */
 68+ public static function getPropertyNames() {
 69+ return array(
 70+ 'timestamp',
 71+ 'url',
 72+ 'size',
 73+ 'dimensions', // For backwards compatibility with Allimages
 74+ 'sha1',
 75+ 'mime',
 76+ 'thumbmime',
 77+ 'metadata',
 78+ 'bitdepth',
 79+ );
 80+ }
7381
 82+
7483 public function getAllowedParams() {
7584 return array(
7685 'sessionkey' => array(
@@ -79,7 +88,7 @@
8089 ),
8190 'prop' => array(
8291 ApiBase::PARAM_ISMULTI => true,
83 - ApiBase::PARAM_DFLT => 'timestamp|user',
 92+ ApiBase::PARAM_DFLT => 'timestamp|url',
8493 ApiBase::PARAM_TYPE => self::getPropertyNames()
8594 ),
8695 'urlwidth' => array(
@@ -89,8 +98,7 @@
9099 'urlheight' => array(
91100 ApiBase::PARAM_TYPE => 'integer',
92101 ApiBase::PARAM_DFLT => -1
93 - ),
94 - 'continue' => null,
 102+ )
95103 );
96104 }
97105
@@ -100,11 +108,23 @@
101109 */
102110 public function getParamDescription() {
103111 $p = $this->getModulePrefix();
104 - $description = array(
 112+ return array(
 113+ 'prop' => array(
 114+ 'What image information to get:',
 115+ ' timestamp - Adds timestamp for the uploaded version',
 116+ ' url - Gives URL to the image and the description page',
 117+ ' size - Adds the size of the image in bytes and the height and width',
 118+ ' dimensions - Alias for size',
 119+ ' sha1 - Adds sha1 hash for the image',
 120+ ' mime - Adds MIME of the image',
 121+ ' thumbmime - Adss MIME of the image thumbnail (requires url)',
 122+ ' metadata - Lists EXIF metadata for the version of the image',
 123+ ' bitdepth - Adds the bit depth of the version',
 124+ ),
 125+ 'sessionkey' => 'Session key that identifies a previous upload that was stashed temporarily.',
105126 'urlwidth' => "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
106 - 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth",
 127+ 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth"
107128 );
108 - return array_merge( $description, $this->getPropParamDescription() );
109129 }
110130
111131 public function getDescription() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r75001followup to r74768, moving this line just for clarity (it works either way)neilk05:06, 19 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74536Refactored so we do not need a special upload module for stashing. Instead, s...neilk04:20, 9 October 2010
r74539module for querying metadata of stashed filesneilk04:27, 9 October 2010

Comments

#Comment by Catrope (talk | contribs)   17:38, 16 October 2010
+				$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $modulePrefix );

You only need to call this once, and you need to call it after adding stuff to the result, not before (the latter is mentioned in the function's docs).

#Comment by NeilK (talk | contribs)   22:52, 19 October 2010

wasn't actually broken, but lined moved for clarity in r75001

#Comment by NeilK (talk | contribs)   22:52, 19 October 2010

wasn't actually broken, but lined moved for clarity in r75001

Status & tagging log