From a910a32f760c38b99d5be658a36679e62a610724 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 3 Sep 2007 21:35:27 +0000 Subject: [PATCH] Return an error message if the requested size was bigger than the source, or more generally if the "transformed" output file is in fact the source file. --- thumb.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/thumb.php b/thumb.php index 2159d2ee65..dbc07c2150 100644 --- a/thumb.php +++ b/thumb.php @@ -69,21 +69,23 @@ try { $thumb = false; } -if ( $thumb && $thumb->getPath() && file_exists( $thumb->getPath() ) ) { - wfStreamFile( $thumb->getPath() ); +$errorMsg = false; +if ( !$img ) { + $errorMsg = wfMsg( 'badtitletext' ); +} elseif ( !$thumb ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' ); +} elseif ( $thumb->isError() ) { + $errorMsg = $thumb->getHtmlMsg(); +} elseif ( !$thumb->getPath() ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); +} elseif ( $thumb->getPath() == $img->getPath() ) { + $errorMsg = wfMsgHtml( 'thumbnail_error', 'Image was not scaled, ' . + 'is the requested width bigger than the source?' ); } else { - if ( !$img ) { - $msg = wfMsg( 'badtitletext' ); - } elseif ( !$thumb ) { - $msg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' ); - } elseif ( $thumb->isError() ) { - $msg = $thumb->getHtmlMsg(); - } elseif ( !$thumb->getPath() ) { - $msg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' ); - } else { - $msg = wfMsgHtml( 'thumbnail_error', 'Output file missing' ); - } - thumbInternalError( $msg ); + wfStreamFile( $thumb->getPath() ); +} +if ( $errorMsg !== false ) { + thumbInternalError( $errorMsg ); } wfProfileOut( 'thumb.php-render' ); -- 2.20.1