From 290e4486a6881766bbe3a9c81b09ac8ee8f92e31 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Fri, 11 Feb 2011 15:40:39 +0000 Subject: [PATCH] * (bug 27199) Thumbnail urls can be fetched for old files as well --- RELEASE-NOTES | 1 + includes/api/ApiQueryImageInfo.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6716250afd..6b69b891ba 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -168,6 +168,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 27205) aiprop=metadata and aiprop=parsedcomment need help text * Add a amtitle param to meta=allmessages * (bug 25832) query=allimages now outputs ns/title as well +* (bug 27199) Thumbnail urls can be fetched for old files as well === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index f742db4ce6..0a8243dd30 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -107,6 +107,9 @@ class ApiQueryImageInfo extends ApiQueryBase { } break; } + + // Check if we can make the requested thumbnail + $this->validateThumbParams( $img, $thumbParams ); // Get information about the current version first // Check that the current version is within the start-end boundaries @@ -117,7 +120,7 @@ class ApiQueryImageInfo extends ApiQueryBase { ) { $gotOne = true; - $this->validateThumbParams( $img, $thumbParams ); + $fit = $this->addPageSubItem( $pageId, self::getInfo( $img, $prop, $result, $thumbParams ) ); if ( !$fit ) { @@ -148,7 +151,7 @@ class ApiQueryImageInfo extends ApiQueryBase { break; } $fit = $this->addPageSubItem( $pageId, - self::getInfo( $oldie, $prop, $result ) ); + self::getInfo( $oldie, $prop, $result, $thumbParams ) ); if ( !$fit ) { if ( count( $pageIds[NS_IMAGE] ) == 1 ) { $this->setContinueEnumParameter( 'start', @@ -301,7 +304,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } } if ( isset( $prop['url'] ) ) { - if ( !is_null( $thumbParams ) && !$file->isOld() ) { + if ( !is_null( $thumbParams ) ) { $mto = $file->transform( $thumbParams ); if ( $mto && !$mto->isError() ) { $vals['thumburl'] = wfExpandUrl( $mto->getUrl() ); @@ -321,6 +324,10 @@ class ApiQueryImageInfo extends ApiQueryBase { $vals['thumbmime'] = $thumbFile->getMimeType(); } } + if ( $mto && $mto->isError() ) { + $this->setWarning( 'Error creating thumbnail for ' . $file->getName . + ': ' . $mto->toText() ); + } } $vals['url'] = $file->getFullURL(); $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); -- 2.20.1