From c09deaa42613c93bbe559efb77c4c8b54c2063f7 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Fri, 25 Feb 2011 19:51:37 +0000 Subject: [PATCH] (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. --- RELEASE-NOTES | 1 + includes/api/ApiQueryImageInfo.php | 113 +++++++++++++++++++---------- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c55f006d13..f6f8bdeba3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -185,6 +185,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 27616) Add userid of blocked user and blocker to list=blocks * (bug 27688) Simplify queries to list user block information * (bug 27708) list=users does not have a property to return user id +* (bug 27715) imageinfo didn't respect revdelete === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 2701730394..23437c1414 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -271,15 +271,18 @@ class ApiQueryImageInfo extends ApiQueryBase { $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() ); } if ( isset( $prop['user'] ) || isset( $prop['userid'] ) ) { - - if ( isset( $prop['user'] ) ) { - $vals['user'] = $file->getUser(); - } - if ( isset( $prop['userid'] ) ) { - $vals['userid'] = $file->getUser( 'id' ); - } - if ( !$file->getUser( 'id' ) ) { - $vals['anon'] = ''; + if ( $file->isDeleted( File::DELETED_USER ) ) { + $vals['userhidden'] = ''; + } else { + if ( isset( $prop['user'] ) ) { + $vals['user'] = $file->getUser(); + } + if ( isset( $prop['userid'] ) ) { + $vals['userid'] = $file->getUser( 'id' ); + } + if ( !$file->getUser( 'id' ) ) { + $vals['anon'] = ''; + } } } if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) { @@ -293,58 +296,90 @@ class ApiQueryImageInfo extends ApiQueryBase { } } if ( isset( $prop['url'] ) ) { - if ( !is_null( $thumbParams ) ) { - $mto = $file->transform( $thumbParams ); - if ( $mto && !$mto->isError() ) { - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() ); - - // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted - // thumbnail sizes for the thumbnail actual size - if ( $mto->getUrl() !== $file->getUrl() ) { - $vals['thumbwidth'] = intval( $mto->getWidth() ); - $vals['thumbheight'] = intval( $mto->getHeight() ); - } else { - $vals['thumbwidth'] = intval( $file->getWidth() ); - $vals['thumbheight'] = intval( $file->getHeight() ); - } + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + if ( !is_null( $thumbParams ) ) { + $mto = $file->transform( $thumbParams ); + if ( $mto && !$mto->isError() ) { + $vals['thumburl'] = wfExpandUrl( $mto->getUrl() ); + + // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted + // thumbnail sizes for the thumbnail actual size + if ( $mto->getUrl() !== $file->getUrl() ) { + $vals['thumbwidth'] = intval( $mto->getWidth() ); + $vals['thumbheight'] = intval( $mto->getHeight() ); + } else { + $vals['thumbwidth'] = intval( $file->getWidth() ); + $vals['thumbheight'] = intval( $file->getHeight() ); + } - if ( isset( $prop['thumbmime'] ) ) { - $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false ); - $vals['thumbmime'] = $thumbFile->getMimeType(); + if ( isset( $prop['thumbmime'] ) ) { + $thumbFile = UnregisteredLocalFile::newFromPath( $mto->getPath(), false ); + $vals['thumbmime'] = $thumbFile->getMimeType(); + } + } else if ( $mto && $mto->isError() ) { + $vals['thumberror'] = $mto->toText(); } - } else if ( $mto && $mto->isError() ) { - $vals['thumberror'] = $mto->toText(); } + $vals['url'] = $file->getFullURL(); + $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); } - $vals['url'] = $file->getFullURL(); - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); } if ( isset( $prop['comment'] ) ) { - $vals['comment'] = $file->getDescription(); + if ( $file->isDeleted( File::DELETED_COMMENT ) ) { + $vals['commenthidden'] = ''; + } else { + $vals['comment'] = $file->getDescription(); + } } if ( isset( $prop['parsedcomment'] ) ) { - global $wgUser; - $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( + if ( $file->isDeleted( File::DELETED_COMMENT ) ) { + $vals['commenthidden'] = ''; + } else { + global $wgUser; + $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $file->getDescription(), $file->getTitle() ); + } } if ( isset( $prop['sha1'] ) ) { - $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 ); + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 ); + } } if ( isset( $prop['metadata'] ) ) { - $metadata = $file->getMetadata(); - $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null; + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + $metadata = $file->getMetadata(); + $vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null; + } } if ( isset( $prop['mime'] ) ) { - $vals['mime'] = $file->getMimeType(); + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + $vals['mime'] = $file->getMimeType(); + } } if ( isset( $prop['archivename'] ) && $file->isOld() ) { - $vals['archivename'] = $file->getArchiveName(); + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + $vals['archivename'] = $file->getArchiveName(); + } } if ( isset( $prop['bitdepth'] ) ) { - $vals['bitdepth'] = $file->getBitDepth(); + if ( $file->isDeleted( File::DELETED_FILE ) ) { + $vals['filehidden'] = ''; + } else { + $vals['bitdepth'] = $file->getBitDepth(); + } } return $vals; -- 2.20.1