From: Gergő Tisza Date: Thu, 5 Feb 2015 02:16:06 +0000 (+0000) Subject: Handle missing width nicely in thumb.php X-Git-Tag: 1.31.0-rc.0~12454^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=769e7e339eea54bcd447f2d3882be2dcbc35b418;p=lhc%2Fweb%2Fwiklou.git Handle missing width nicely in thumb.php Bug: T88508 Change-Id: I2cbe4ab914a9edba71461b194151938feeafeb11 --- diff --git a/autoload.php b/autoload.php index 948a6aa421..8542e5f7f1 100644 --- a/autoload.php +++ b/autoload.php @@ -725,6 +725,7 @@ $wgAutoloadLocalClasses = array( 'MediaHandler' => __DIR__ . '/includes/media/MediaHandler.php', 'MediaStatisticsPage' => __DIR__ . '/includes/specials/SpecialMediaStatistics.php', 'MediaTransformError' => __DIR__ . '/includes/media/MediaTransformOutput.php', + 'MediaTransformInvalidParametersException' => __DIR__ . '/includes/media/MediaTransformInvalidParametersException.php', 'MediaTransformOutput' => __DIR__ . '/includes/media/MediaTransformOutput.php', 'MediaWiki' => __DIR__ . '/includes/MediaWiki.php', 'MediaWikiBagOStuff' => __DIR__ . '/includes/objectcache/SqlBagOStuff.php', diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php index 6dd0453ef1..787f21e443 100644 --- a/includes/media/ImageHandler.php +++ b/includes/media/ImageHandler.php @@ -57,7 +57,7 @@ abstract class ImageHandler extends MediaHandler { } elseif ( isset( $params['width'] ) ) { $width = $params['width']; } else { - throw new MWException( 'No width specified to ' . __METHOD__ ); + throw new MediaTransformInvalidParametersException( 'No width specified to ' . __METHOD__ ); } # Removed for ProofreadPage diff --git a/includes/media/MediaTransformInvalidParametersException.php b/includes/media/MediaTransformInvalidParametersException.php new file mode 100644 index 0000000000..15a2ca5546 --- /dev/null +++ b/includes/media/MediaTransformInvalidParametersException.php @@ -0,0 +1,26 @@ +thumbName( $params ); if ( !strlen( $thumbName ) ) { // invalid params? - wfThumbError( 400, 'The specified thumbnail parameters are not valid.' ); - return; + throw new MediaTransformInvalidParametersException( 'Empty return from File::thumbName' ); } $thumbName2 = $img->thumbName( $params, File::THUMB_FULL_NAME ); // b/c; "long" style + } catch ( MediaTransformInvalidParametersException $e ) { + wfThumbError( 400, 'The specified thumbnail parameters are not valid: ' . $e->getMessage() ); + return; } catch ( MWException $e ) { wfThumbError( 500, $e->getHTML() ); return;