r82814 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82813‎ | r82814 | r82815 >
Date:20:22, 25 February 2011
Author:reedy
Status:ok
Tags:
Comment:
One minor followup to r82810

return $vals; early, rather than indenting all of the code another level
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -288,6 +288,7 @@
289289 }
290290 }
291291 }
 292+
292293 // This is shown even if the file is revdelete'd in interface
293294 // so do same here.
294295 if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
@@ -314,58 +315,60 @@
315316 }
316317 }
317318
318 -
319319 if ( $file->isDeleted( File::DELETED_FILE ) ) {
320320 $vals['filehidden'] = '';
321 - } else {
322 - if ( isset( $prop['url'] ) ) {
323 - if ( !is_null( $thumbParams ) ) {
324 - $mto = $file->transform( $thumbParams );
325 - if ( $mto && !$mto->isError() ) {
326 - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
327321
328 - // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
329 - // thumbnail sizes for the thumbnail actual size
330 - if ( $mto->getUrl() !== $file->getUrl() ) {
331 - $vals['thumbwidth'] = intval( $mto->getWidth() );
332 - $vals['thumbheight'] = intval( $mto->getHeight() );
333 - } else {
334 - $vals['thumbwidth'] = intval( $file->getWidth() );
335 - $vals['thumbheight'] = intval( $file->getHeight() );
336 - }
 322+ //Early return, tidier than indenting all following things one level
 323+ return $vals;
 324+ }
337325
338 - if ( isset( $prop['thumbmime'] ) ) {
339 - $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false );
340 - $vals['thumbmime'] = $thumbFile->getMimeType();
341 - }
342 - } else if ( $mto && $mto->isError() ) {
343 - $vals['thumberror'] = $mto->toText();
 326+ if ( isset( $prop['url'] ) ) {
 327+ if ( !is_null( $thumbParams ) ) {
 328+ $mto = $file->transform( $thumbParams );
 329+ if ( $mto && !$mto->isError() ) {
 330+ $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
 331+
 332+ // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
 333+ // thumbnail sizes for the thumbnail actual size
 334+ if ( $mto->getUrl() !== $file->getUrl() ) {
 335+ $vals['thumbwidth'] = intval( $mto->getWidth() );
 336+ $vals['thumbheight'] = intval( $mto->getHeight() );
 337+ } else {
 338+ $vals['thumbwidth'] = intval( $file->getWidth() );
 339+ $vals['thumbheight'] = intval( $file->getHeight() );
344340 }
 341+
 342+ if ( isset( $prop['thumbmime'] ) ) {
 343+ $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false );
 344+ $vals['thumbmime'] = $thumbFile->getMimeType();
 345+ }
 346+ } else if ( $mto && $mto->isError() ) {
 347+ $vals['thumberror'] = $mto->toText();
345348 }
346 - $vals['url'] = $file->getFullURL();
347 - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
348349 }
 350+ $vals['url'] = $file->getFullURL();
 351+ $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
 352+ }
349353
350 - if ( isset( $prop['sha1'] ) ) {
351 - $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
352 - }
 354+ if ( isset( $prop['sha1'] ) ) {
 355+ $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
 356+ }
353357
354 - if ( isset( $prop['metadata'] ) ) {
355 - $metadata = $file->getMetadata();
356 - $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
357 - }
 358+ if ( isset( $prop['metadata'] ) ) {
 359+ $metadata = $file->getMetadata();
 360+ $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
 361+ }
358362
359 - if ( isset( $prop['mime'] ) ) {
360 - $vals['mime'] = $file->getMimeType();
361 - }
 363+ if ( isset( $prop['mime'] ) ) {
 364+ $vals['mime'] = $file->getMimeType();
 365+ }
362366
363 - if ( isset( $prop['archivename'] ) && $file->isOld() ) {
364 - $vals['archivename'] = $file->getArchiveName();
365 - }
 367+ if ( isset( $prop['archivename'] ) && $file->isOld() ) {
 368+ $vals['archivename'] = $file->getArchiveName();
 369+ }
366370
367 - if ( isset( $prop['bitdepth'] ) ) {
368 - $vals['bitdepth'] = $file->getBitDepth();
369 - }
 371+ if ( isset( $prop['bitdepth'] ) ) {
 372+ $vals['bitdepth'] = $file->getBitDepth();
370373 }
371374
372375 return $vals;

Follow-up revisions

RevisionCommit summaryAuthorDate
r82818Followup r82810, r82813, r82814...reedy21:41, 25 February 2011
r82819MFT r82810, r82813, r82814, r82815, r82818reedy21:45, 25 February 2011
r82820MFT r82810, r82813, r82814, r82815, r82818reedy21:46, 25 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82810(bug 27715) Make imageinfo api module respect revDelete....bawolff19:51, 25 February 2011

Status & tagging log