r82818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82817‎ | r82818 | r82819 >
Date:21:41, 25 February 2011
Author:reedy
Status:ok
Tags:
Comment:
Followup r82810, r82813, r82814

Only display hidden stuff if any vaguely related property is set
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -273,14 +273,17 @@
274274 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
275275 }
276276
277 - if ( $file->isDeleted( File::DELETED_USER ) ) {
278 - $vals['userhidden'] = '';
279 - } else {
280 - if ( isset( $prop['user'] ) || isset( $prop['userid'] ) ) {
281 - if ( isset( $prop['user'] ) ) {
 277+ $user = isset( $prop['user'] );
 278+ $userid = isset( $prop['userid'] );
 279+
 280+ if ( $user || $userid ) {
 281+ if ( $file->isDeleted( File::DELETED_USER ) ) {
 282+ $vals['userhidden'] = '';
 283+ } else {
 284+ if ( $user ) {
282285 $vals['user'] = $file->getUser();
283286 }
284 - if ( isset( $prop['userid'] ) ) {
 287+ if ( $userid ) {
285288 $vals['userid'] = $file->getUser( 'id' );
286289 }
287290 if ( !$file->getUser( 'id' ) ) {
@@ -302,27 +305,40 @@
303306 }
304307 }
305308
306 - if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
307 - $vals['commenthidden'] = '';
308 - } else {
309 - if ( isset( $prop['parsedcomment'] ) ) {
310 - global $wgUser;
311 - $vals['parsedcomment'] = $wgUser->getSkin()->formatComment(
312 - $file->getDescription(), $file->getTitle() );
 309+ $pcomment = isset( $prop['parsedcomment'] );
 310+ $comment = isset( $prop['comment'] );
 311+
 312+ if ( $pcomment || $comment ) {
 313+ if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
 314+ $vals['commenthidden'] = '';
 315+ } else {
 316+ if ( $pcomment ) {
 317+ global $wgUser;
 318+ $vals['parsedcomment'] = $wgUser->getSkin()->formatComment(
 319+ $file->getDescription(), $file->getTitle() );
 320+ }
 321+ if ( $comment ) {
 322+ $vals['comment'] = $file->getDescription();
 323+ }
313324 }
314 - if ( isset( $prop['comment'] ) ) {
315 - $vals['comment'] = $file->getDescription();
316 - }
317325 }
318326
319 - if ( $file->isDeleted( File::DELETED_FILE ) ) {
 327+ $url = isset( $prop['url'] );
 328+ $sha1 = isset( $prop['sha1'] );
 329+ $meta = isset( $prop['metadata'] );
 330+ $mime = isset( $prop['mime'] );
 331+ $archive = isset( $prop['archivename'] );
 332+ $bitdepth = isset( $prop['bitdepth'] );
 333+
 334+ if ( ( $url || $sha1 || $meta || $mime || $archive || $bitdepth )
 335+ && $file->isDeleted( File::DELETED_FILE ) ) {
320336 $vals['filehidden'] = '';
321337
322338 //Early return, tidier than indenting all following things one level
323339 return $vals;
324340 }
325341
326 - if ( isset( $prop['url'] ) ) {
 342+ if ( $url ) {
327343 if ( !is_null( $thumbParams ) ) {
328344 $mto = $file->transform( $thumbParams );
329345 if ( $mto && !$mto->isError() ) {
@@ -350,24 +366,24 @@
351367 $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
352368 }
353369
354 - if ( isset( $prop['sha1'] ) ) {
 370+ if ( $sha1 ) {
355371 $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
356372 }
357373
358 - if ( isset( $prop['metadata'] ) ) {
 374+ if ( $meta ) {
359375 $metadata = $file->getMetadata();
360376 $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
361377 }
362378
363 - if ( isset( $prop['mime'] ) ) {
 379+ if ( $mime ) {
364380 $vals['mime'] = $file->getMimeType();
365381 }
366382
367 - if ( isset( $prop['archivename'] ) && $file->isOld() ) {
 383+ if ( $archive && $file->isOld() ) {
368384 $vals['archivename'] = $file->getArchiveName();
369385 }
370386
371 - if ( isset( $prop['bitdepth'] ) ) {
 387+ if ( $bitdepth ) {
372388 $vals['bitdepth'] = $file->getBitDepth();
373389 }
374390

Follow-up revisions

RevisionCommit summaryAuthorDate
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
r82813(follow-up r82810) Address Reedy's comments on irc.bawolff20:16, 25 February 2011
r82814One minor followup to r82810...reedy20:22, 25 February 2011

Status & tagging log