Index: trunk/phase3/includes/api/ApiQueryImageInfo.php |
— | — | @@ -273,14 +273,17 @@ |
274 | 274 | $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() ); |
275 | 275 | } |
276 | 276 | |
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 ) { |
282 | 285 | $vals['user'] = $file->getUser(); |
283 | 286 | } |
284 | | - if ( isset( $prop['userid'] ) ) { |
| 287 | + if ( $userid ) { |
285 | 288 | $vals['userid'] = $file->getUser( 'id' ); |
286 | 289 | } |
287 | 290 | if ( !$file->getUser( 'id' ) ) { |
— | — | @@ -302,27 +305,40 @@ |
303 | 306 | } |
304 | 307 | } |
305 | 308 | |
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 | + } |
313 | 324 | } |
314 | | - if ( isset( $prop['comment'] ) ) { |
315 | | - $vals['comment'] = $file->getDescription(); |
316 | | - } |
317 | 325 | } |
318 | 326 | |
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 ) ) { |
320 | 336 | $vals['filehidden'] = ''; |
321 | 337 | |
322 | 338 | //Early return, tidier than indenting all following things one level |
323 | 339 | return $vals; |
324 | 340 | } |
325 | 341 | |
326 | | - if ( isset( $prop['url'] ) ) { |
| 342 | + if ( $url ) { |
327 | 343 | if ( !is_null( $thumbParams ) ) { |
328 | 344 | $mto = $file->transform( $thumbParams ); |
329 | 345 | if ( $mto && !$mto->isError() ) { |
— | — | @@ -350,24 +366,24 @@ |
351 | 367 | $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); |
352 | 368 | } |
353 | 369 | |
354 | | - if ( isset( $prop['sha1'] ) ) { |
| 370 | + if ( $sha1 ) { |
355 | 371 | $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 ); |
356 | 372 | } |
357 | 373 | |
358 | | - if ( isset( $prop['metadata'] ) ) { |
| 374 | + if ( $meta ) { |
359 | 375 | $metadata = $file->getMetadata(); |
360 | 376 | $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null; |
361 | 377 | } |
362 | 378 | |
363 | | - if ( isset( $prop['mime'] ) ) { |
| 379 | + if ( $mime ) { |
364 | 380 | $vals['mime'] = $file->getMimeType(); |
365 | 381 | } |
366 | 382 | |
367 | | - if ( isset( $prop['archivename'] ) && $file->isOld() ) { |
| 383 | + if ( $archive && $file->isOld() ) { |
368 | 384 | $vals['archivename'] = $file->getArchiveName(); |
369 | 385 | } |
370 | 386 | |
371 | | - if ( isset( $prop['bitdepth'] ) ) { |
| 387 | + if ( $bitdepth ) { |
372 | 388 | $vals['bitdepth'] = $file->getBitDepth(); |
373 | 389 | } |
374 | 390 | |