r25461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25460‎ | r25461 | r25462 >
Date:21:35, 3 September 2007
Author:tstarling
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/thumb.php (modified) (history)

Diff [purge]

Index: trunk/phase3/thumb.php
@@ -69,22 +69,24 @@
7070 $thumb = false;
7171 }
7272
73 -if ( $thumb && $thumb->getPath() && file_exists( $thumb->getPath() ) ) {
 73+$errorMsg = false;
 74+if ( !$img ) {
 75+ $errorMsg = wfMsg( 'badtitletext' );
 76+} elseif ( !$thumb ) {
 77+ $errorMsg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' );
 78+} elseif ( $thumb->isError() ) {
 79+ $errorMsg = $thumb->getHtmlMsg();
 80+} elseif ( !$thumb->getPath() ) {
 81+ $errorMsg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' );
 82+} elseif ( $thumb->getPath() == $img->getPath() ) {
 83+ $errorMsg = wfMsgHtml( 'thumbnail_error', 'Image was not scaled, ' .
 84+ 'is the requested width bigger than the source?' );
 85+} else {
7486 wfStreamFile( $thumb->getPath() );
75 -} else {
76 - if ( !$img ) {
77 - $msg = wfMsg( 'badtitletext' );
78 - } elseif ( !$thumb ) {
79 - $msg = wfMsgHtml( 'thumbnail_error', 'File::transform() returned false' );
80 - } elseif ( $thumb->isError() ) {
81 - $msg = $thumb->getHtmlMsg();
82 - } elseif ( !$thumb->getPath() ) {
83 - $msg = wfMsgHtml( 'thumbnail_error', 'No path supplied in thumbnail object' );
84 - } else {
85 - $msg = wfMsgHtml( 'thumbnail_error', 'Output file missing' );
86 - }
87 - thumbInternalError( $msg );
8887 }
 88+if ( $errorMsg !== false ) {
 89+ thumbInternalError( $errorMsg );
 90+}
8991
9092 wfProfileOut( 'thumb.php-render' );
9193 wfProfileOut( 'thumb.php' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r25530Merged revisions 25454-25529 via svnmerge from...david08:28, 5 September 2007

Status & tagging log