r82810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82809‎ | r82810 | r82811 >
Date:19:51, 25 February 2011
Author:bawolff
Status:resolved
Tags:
Comment:
(bug 27715) Make imageinfo api module respect revDelete.

This treats metadata and similar properties to be deleted if the file is deleted, since they
are derived from the file, and i know examples of where the file was deleted to hide sensitive
data in exif. Does still show the file size if file is deleted, because that is what is done
in interface. Follows what ApiQueryLogEvents does and outputs userhidden="" if the user cannot
be displayed due to being hidden.

Due to this bug, all the secret oversight cabal info could be visible for images, so probably
should be merged into wmf stuff soon as possible.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -271,16 +271,19 @@
272272 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
273273 }
274274 if ( isset( $prop['user'] ) || isset( $prop['userid'] ) ) {
275 -
276 - if ( isset( $prop['user'] ) ) {
277 - $vals['user'] = $file->getUser();
 275+ if ( $file->isDeleted( File::DELETED_USER ) ) {
 276+ $vals['userhidden'] = '';
 277+ } else {
 278+ if ( isset( $prop['user'] ) ) {
 279+ $vals['user'] = $file->getUser();
 280+ }
 281+ if ( isset( $prop['userid'] ) ) {
 282+ $vals['userid'] = $file->getUser( 'id' );
 283+ }
 284+ if ( !$file->getUser( 'id' ) ) {
 285+ $vals['anon'] = '';
 286+ }
278287 }
279 - if ( isset( $prop['userid'] ) ) {
280 - $vals['userid'] = $file->getUser( 'id' );
281 - }
282 - if ( !$file->getUser( 'id' ) ) {
283 - $vals['anon'] = '';
284 - }
285288 }
286289 if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
287290 $vals['size'] = intval( $file->getSize() );
@@ -293,58 +296,90 @@
294297 }
295298 }
296299 if ( isset( $prop['url'] ) ) {
297 - if ( !is_null( $thumbParams ) ) {
298 - $mto = $file->transform( $thumbParams );
299 - if ( $mto && !$mto->isError() ) {
300 - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
 300+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 301+ $vals['filehidden'] = '';
 302+ } else {
 303+ if ( !is_null( $thumbParams ) ) {
 304+ $mto = $file->transform( $thumbParams );
 305+ if ( $mto && !$mto->isError() ) {
 306+ $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
301307
302 - // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
303 - // thumbnail sizes for the thumbnail actual size
304 - if ( $mto->getUrl() !== $file->getUrl() ) {
305 - $vals['thumbwidth'] = intval( $mto->getWidth() );
306 - $vals['thumbheight'] = intval( $mto->getHeight() );
307 - } else {
308 - $vals['thumbwidth'] = intval( $file->getWidth() );
309 - $vals['thumbheight'] = intval( $file->getHeight() );
310 - }
 308+ // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
 309+ // thumbnail sizes for the thumbnail actual size
 310+ if ( $mto->getUrl() !== $file->getUrl() ) {
 311+ $vals['thumbwidth'] = intval( $mto->getWidth() );
 312+ $vals['thumbheight'] = intval( $mto->getHeight() );
 313+ } else {
 314+ $vals['thumbwidth'] = intval( $file->getWidth() );
 315+ $vals['thumbheight'] = intval( $file->getHeight() );
 316+ }
311317
312 - if ( isset( $prop['thumbmime'] ) ) {
313 - $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false );
314 - $vals['thumbmime'] = $thumbFile->getMimeType();
 318+ if ( isset( $prop['thumbmime'] ) ) {
 319+ $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false );
 320+ $vals['thumbmime'] = $thumbFile->getMimeType();
 321+ }
 322+ } else if ( $mto && $mto->isError() ) {
 323+ $vals['thumberror'] = $mto->toText();
315324 }
316 - } else if ( $mto && $mto->isError() ) {
317 - $vals['thumberror'] = $mto->toText();
318325 }
 326+ $vals['url'] = $file->getFullURL();
 327+ $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
319328 }
320 - $vals['url'] = $file->getFullURL();
321 - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
322329 }
323330 if ( isset( $prop['comment'] ) ) {
324 - $vals['comment'] = $file->getDescription();
 331+ if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
 332+ $vals['commenthidden'] = '';
 333+ } else {
 334+ $vals['comment'] = $file->getDescription();
 335+ }
325336 }
326337 if ( isset( $prop['parsedcomment'] ) ) {
327 - global $wgUser;
328 - $vals['parsedcomment'] = $wgUser->getSkin()->formatComment(
 338+ if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
 339+ $vals['commenthidden'] = '';
 340+ } else {
 341+ global $wgUser;
 342+ $vals['parsedcomment'] = $wgUser->getSkin()->formatComment(
329343 $file->getDescription(), $file->getTitle() );
 344+ }
330345 }
331346
332347 if ( isset( $prop['sha1'] ) ) {
333 - $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
 348+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 349+ $vals['filehidden'] = '';
 350+ } else {
 351+ $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
 352+ }
334353 }
335354 if ( isset( $prop['metadata'] ) ) {
336 - $metadata = $file->getMetadata();
337 - $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
 355+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 356+ $vals['filehidden'] = '';
 357+ } else {
 358+ $metadata = $file->getMetadata();
 359+ $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
 360+ }
338361 }
339362 if ( isset( $prop['mime'] ) ) {
340 - $vals['mime'] = $file->getMimeType();
 363+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 364+ $vals['filehidden'] = '';
 365+ } else {
 366+ $vals['mime'] = $file->getMimeType();
 367+ }
341368 }
342369
343370 if ( isset( $prop['archivename'] ) && $file->isOld() ) {
344 - $vals['archivename'] = $file->getArchiveName();
 371+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 372+ $vals['filehidden'] = '';
 373+ } else {
 374+ $vals['archivename'] = $file->getArchiveName();
 375+ }
345376 }
346377
347378 if ( isset( $prop['bitdepth'] ) ) {
348 - $vals['bitdepth'] = $file->getBitDepth();
 379+ if ( $file->isDeleted( File::DELETED_FILE ) ) {
 380+ $vals['filehidden'] = '';
 381+ } else {
 382+ $vals['bitdepth'] = $file->getBitDepth();
 383+ }
349384 }
350385
351386 return $vals;
Index: trunk/phase3/RELEASE-NOTES
@@ -185,6 +185,7 @@
186186 * (bug 27616) Add userid of blocked user and blocker to list=blocks
187187 * (bug 27688) Simplify queries to list user block information
188188 * (bug 27708) list=users does not have a property to return user id
 189+* (bug 27715) imageinfo didn't respect revdelete
189190
190191 === Languages updated in 1.18 ===
191192

Sign-offs

UserFlagDate
Bryaninspected11:35, 26 February 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
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
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

Status & tagging log