Bypass TransformTooBigImageAreaError for ForeignApiFile
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 24 Jan 2015 17:30:17 +0000 (18:30 +0100)
committerUmherirrender <umherirrender_de.wp@web.de>
Tue, 26 May 2015 05:05:00 +0000 (05:05 +0000)
The check if the image area is smaller than $wgMaxImageArea can be
bypassed for ForeignApiFile, because the transform of the file is done
on another physical server and therefore has it own check for
$wgMaxImageArea.
A possible TransformTooBigImageAreaError from the foreign server will be
shown when needed (Prepended by message 'thumbnail_error_remote').

Bug: T34387
Change-Id: Iccb25c00e132a4fe744840b7b8db7d9af620bce2

includes/filerepo/file/File.php
includes/filerepo/file/ForeignAPIFile.php
includes/media/TransformationalImageHandler.php

index eb50a12..76ed27b 100644 (file)
@@ -2231,4 +2231,13 @@ abstract class File implements IDBAccessObject {
                $handler = $this->getHandler();
                return $handler ? $handler->isExpensiveToThumbnail( $this ) : false;
        }
+
+       /**
+        * Whether the thumbnails created on the same server as this code is running.
+        * @since 1.25
+        * @return bool
+        */
+       public function isTransformedLocally() {
+               return true;
+       }
 }
index e51f381..3c78290 100644 (file)
@@ -369,4 +369,13 @@ class ForeignAPIFile extends File {
                # Clear out the thumbnail directory if empty
                $this->repo->quickCleanDir( $dir );
        }
+
+       /**
+        * The thumbnail is created on the foreign server and fetched over internet
+        * @since 1.25
+        * @return bool
+        */
+       public function isTransformedLocally() {
+               return false;
+       }
 }
index fd8d81d..15753a9 100644 (file)
@@ -167,7 +167,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
                        return $this->getClientScalingThumbnailImage( $image, $scalerParams );
                }
 
-               if ( !$this->isImageAreaOkForThumbnaling( $image, $params ) ) {
+               if ( $image->isTransformedLocally() && !$this->isImageAreaOkForThumbnaling( $image, $params ) ) {
                        global $wgMaxImageArea;
                        return new TransformTooBigImageAreaError( $params, $wgMaxImageArea );
                }