From 7fcb8f91dcf263224374dcadecd1eac30006e81d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 22 Jan 2008 03:31:10 +0000 Subject: [PATCH] * (bug 11593, 12719) Fixes for overzealous invocation of thumb.php. Non-image handlers and full-size images may now decline it, fixing mystery failures when using $wgThumbnailScriptPath. --- RELEASE-NOTES | 3 +++ includes/filerepo/File.php | 8 +++++--- includes/media/Generic.php | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fb5b0d08f9..6641c0fcb0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -327,6 +327,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 12695) Suppress dvips verbiage from web server error log * (bug 12716) Unprotecting a non-protected page leaves a log entry * Log username blocks with canonical form of name instead of input form +* (bug 11593, 12719) Fixes for overzealous invocation of thumb.php. + Non-image handlers and full-size images may now decline it, fixing + mystery failures when using $wgThumbnailScriptPath. == Parser changes in 1.12 == diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index c913022f20..f4b28dbf18 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -505,9 +505,11 @@ abstract class File { $script = $this->getTransformScript(); if ( $script && !($flags & self::RENDER_NOW) ) { - // Use a script to transform on client request + // Use a script to transform on client request, if possible $thumb = $this->handler->getScriptedTransform( $this, $script, $params ); - break; + if( $thumb ) { + break; + } } $normalisedParams = $params; @@ -515,7 +517,7 @@ abstract class File { $thumbName = $this->thumbName( $normalisedParams ); $thumbPath = $this->getThumbPath( $thumbName ); $thumbUrl = $this->getThumbUrl( $thumbName ); - + if ( $this->repo->canTransformVia404() && !($flags & self::RENDER_NOW ) ) { $thumb = $this->handler->getTransform( $this, $thumbPath, $thumbUrl, $params ); break; diff --git a/includes/media/Generic.php b/includes/media/Generic.php index b804422e90..199149296f 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -96,6 +96,19 @@ abstract class MediaHandler { */ function isMetadataValid( $image, $metadata ) { return true; } + + /** + * Get a MediaTransformOutput object representing an alternate of the transformed + * output which will call an intermediary thumbnail assist script. + * + * Used when the repository has a thumbnailScriptUrl option configured. + * + * Return false to fall back to the regular getTransform(). + */ + function getScriptedTransform( $image, $script, $params ) { + return false; + } + /** * Get a MediaTransformOutput object representing the transformed output. Does not * actually do the transform. @@ -372,7 +385,10 @@ abstract class ImageHandler extends MediaHandler { } $url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) ); $page = isset( $params['page'] ) ? $params['page'] : false; - return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page ); + + if( $image->mustRender() || $params['width'] < $image->getWidth() ) { + return new ThumbnailImage( $image, $url, $params['width'], $params['height'], $page ); + } } function getImageSize( $image, $path ) { -- 2.20.1