r92459 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92458‎ | r92459 | r92460 >
Date:19:31, 18 July 2011
Author:raindrift
Status:resolved (Comments)
Tags:
Comment:
changed sessionkey to filekey to keep consistent with the rest of UploadStash (while retaining sessionkey for backwards compatibility)
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryStashImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryStashImageInfo.php
@@ -41,11 +41,15 @@
4242
4343 $result = $this->getResult();
4444
 45+ if ( !$params['filekey'] && !$params['sessionkey'] ) {
 46+ $this->dieUsage( "One of filekey or sessionkey must be supplied", 'nofilekey');
 47+ }
 48+
4549 try {
4650 $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
4751
48 - foreach ( $params['sessionkey'] as $sessionkey ) {
49 - $file = $stash->getFile( $sessionkey );
 52+ foreach ( $params['filekey'] as $filekey ) {
 53+ $file = $stash->getFile( $filekey );
5054 $finalThumbParam = $this->mergeThumbParams( $file, $scale, $params['urlparam'] );
5155 $imageInfo = ApiQueryImageInfo::getInfo( $file, $prop, $result, $finalThumbParam );
5256 $result->addValue( array( 'query', $this->getModuleName() ), null, $imageInfo );
@@ -68,9 +72,13 @@
6973
7074 public function getAllowedParams() {
7175 return array(
 76+ 'filekey' => array(
 77+ ApiBase::PARAM_ISMULTI => true,
 78+ ApiBase::PARAM_DFLT => null
 79+ ),
7280 'sessionkey' => array(
7381 ApiBase::PARAM_ISMULTI => true,
74 - ApiBase::PARAM_REQUIRED => true,
 82+ ApiBase::PARAM_DEPRECATED => true,
7583 ApiBase::PARAM_DFLT => null
7684 ),
7785 'prop' => array(
@@ -101,7 +109,8 @@
102110 $p = $this->getModulePrefix();
103111 return array(
104112 'prop' => self::getPropertyDescriptions( $this->propertyFilter ),
105 - 'sessionkey' => 'Session key that identifies a previous upload that was stashed temporarily.',
 113+ 'filekey' => 'Key that identifies a previous upload that was stashed temporarily.',
 114+ 'sessionkey' => 'Alias for filekey, for backward compatibility.',
106115 'urlwidth' => "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
107116 'urlheight' => "Similar to {$p}urlwidth. Cannot be used without {$p}urlwidth",
108117 'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
@@ -115,8 +124,8 @@
116125
117126 protected function getExamples() {
118127 return array(
119 - 'api.php?action=query&prop=stashimageinfo&siisessionkey=124sd34rsdf567',
120 - 'api.php?action=query&prop=stashimageinfo&siisessionkey=b34edoe3|bceffd4&siiurlwidth=120&siiprop=url',
 128+ 'api.php?action=query&prop=stashimageinfo&siifilekey=124sd34rsdf567',
 129+ 'api.php?action=query&prop=stashimageinfo&siifilekey=b34edoe3|bceffd4&siiurlwidth=120&siiprop=url',
121130 );
122131 }
123132

Follow-up revisions

RevisionCommit summaryAuthorDate
r92815Actually alias sessionkey to filekey, fixes bug in r92459raindrift22:28, 21 July 2011

Comments

#Comment by Catrope (talk | contribs)   18:34, 21 July 2011

This claims sessionkey is an alias for filekey, but it doesn't actually do the aliasing. I.e. if sessionkey is set but filekey isn't, its value isn't used.

#Comment by Raindrift (talk | contribs)   22:28, 21 July 2011

Wow. Thanks for catching that! That's totally lame! Fixed in r92815.

Status & tagging log