Avoid attempting to prerender thumbnails that will fail
authorGilles Dubuc <gdubuc@wikimedia.org>
Fri, 3 Oct 2014 16:09:07 +0000 (18:09 +0200)
committerGilles Dubuc <gdubuc@wikimedia.org>
Fri, 3 Oct 2014 16:09:07 +0000 (18:09 +0200)
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

index eb54e58..db0239c 100644 (file)
@@ -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 );
+               }
        }
 
        /**