* Cleaner error behavior on thumb.php with invalid page selection
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 2 Oct 2006 21:12:28 +0000 (21:12 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 2 Oct 2006 21:12:28 +0000 (21:12 +0000)
RELEASE-NOTES
includes/Image.php
thumb.php

index 7535f75..1e1f8fd 100644 (file)
@@ -253,6 +253,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   Special:Allmessages by a factor of 16
 * Committed a bunch of live hacks from Wikimedia servers
 * (bug 6889) PHP notices in thumb.php with missing params
+* Cleaner error behavior on thumb.php with invalid page selection
 
 
 == Languages updated ==
index 2596036..48dcc6b 100644 (file)
@@ -2282,7 +2282,9 @@ class Image
                                __METHOD__
                        );
                }
+               wfSuppressWarnings();
                $this->multiPageXML = new SimpleXMLElement( $this->metadata );
+               wfRestoreWarnings();
        }
 
        /**
index 4ec40dc..a056dcc 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -54,12 +54,17 @@ require_once( 'Setup.php' );
 wfProfileIn( 'thumb.php-render' );
 
 $img = Image::newFromName( $fileName );
-if ( $img ) {
-       if ( ! is_null( $page ) ) {
-               $img->selectPage( $page );
+try {
+       if ( $img ) {
+               if ( ! is_null( $page ) ) {
+                       $img->selectPage( $page );
+               }
+               $thumb = $img->renderThumb( $width, false );
+       } else {
+               $thumb = false;
        }
-       $thumb = $img->renderThumb( $width, false );
-} else {
+} catch( Exception $ex ) {
+       // Tried to select a page on a non-paged file?
        $thumb = false;
 }