From 516265fa17124143e126a69f41fc13b704d0887b Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 24 Jan 2015 18:30:17 +0100 Subject: [PATCH] Bypass TransformTooBigImageAreaError for ForeignApiFile 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 | 9 +++++++++ includes/filerepo/file/ForeignAPIFile.php | 9 +++++++++ includes/media/TransformationalImageHandler.php | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index eb50a12924..76ed27b337 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -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; + } } diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index e51f381c31..3c78290c27 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -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; + } } diff --git a/includes/media/TransformationalImageHandler.php b/includes/media/TransformationalImageHandler.php index fd8d81d24c..15753a96eb 100644 --- a/includes/media/TransformationalImageHandler.php +++ b/includes/media/TransformationalImageHandler.php @@ -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 ); } -- 2.20.1