* (bug 11593, 12719) Fixes for overzealous invocation of thumb.php.
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 22 Jan 2008 03:31:10 +0000 (03:31 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 22 Jan 2008 03:31:10 +0000 (03:31 +0000)
  Non-image handlers and full-size images may now decline it, fixing
  mystery failures when using $wgThumbnailScriptPath.

RELEASE-NOTES
includes/filerepo/File.php
includes/media/Generic.php

index fb5b0d0..6641c0f 100644 (file)
@@ -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 ==
index c913022..f4b28db 100644 (file)
@@ -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;
index b804422..1991492 100644 (file)
@@ -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 ) {