From: umherirrender Date: Sat, 24 Jan 2015 17:30:17 +0000 (+0100) Subject: Bypass TransformTooBigImageAreaError for ForeignApiFile X-Git-Tag: 1.31.0-rc.0~11276^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=516265fa17124143e126a69f41fc13b704d0887b;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ); }