From 0ce5bafb4ba521497ea175a8bb61d437ecbb8453 Mon Sep 17 00:00:00 2001 From: Gilles Dubuc Date: Fri, 3 Oct 2014 18:09:07 +0200 Subject: [PATCH] Avoid attempting to prerender thumbnails that will fail For non-vectorial content, requesting a thumbnail larger than the original results in a 500. Prerendering in its current form introduces an increase in 500s that dilutes the real problematic 500s, making troubleshooting harder than it needs to be. Change-Id: I9418dee7653ad7954c3788ecdd350fc8772edd32 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/301 --- includes/upload/UploadBase.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index eb54e5830a..db0239cf49 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -768,13 +768,20 @@ abstract class UploadBase { $sizes = $wgUploadThumbnailRenderMap; rsort( $sizes ); + $file = $this->getLocalFile(); + foreach ( $sizes as $size ) { - $jobs[] = new ThumbnailRenderJob( $this->getLocalFile()->getTitle(), array( - 'transformParams' => array( 'width' => $size ), - ) ); + if ( $file->isVectorized() + || $file->getWidth() > $size ) { + $jobs[] = new ThumbnailRenderJob( $file->getTitle(), array( + 'transformParams' => array( 'width' => $size ), + ) ); + } } - JobQueueGroup::singleton()->push( $jobs ); + if ( $jobs ) { + JobQueueGroup::singleton()->push( $jobs ); + } } /** -- 2.20.1