From a90c8f87b2e7c2d26d148b1d2679e02441539291 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 23 Mar 2011 21:21:31 +0000 Subject: [PATCH] * Follow-up r84610: don't assume a Parser object is attached * Removed unused $i var --- includes/ImageGallery.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index ce4404b289..4ee9a77ea3 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -247,7 +247,7 @@ class ImageGallery } $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights ); - $i = 0; + # Output each image... foreach ( $this->mImages as $pair ) { $nt = $pair[0]; $text = $pair[1]; # "text" means "caption" here @@ -257,8 +257,20 @@ class ImageGallery $time = $sha1 = $descQuery = false; wfRunHooks( 'BeforeGalleryFindFile', array( &$this, &$nt, &$time, &$descQuery, &$sha1 ) ); - # Fetch and register the file (file title may be different via hooks) - list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 ); + # Get the file... + if ( $this->mParser instanceof Parser ) { + # Fetch and register the file (file title may be different via hooks) + list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 ); + } else { + if ( $time === '0' ) { + $img = false; // broken thumbnail forced by hook + } elseif ( $sha1 ) { // get by (sha1,timestamp) + $img = RepoGroup::singleton()->findFileFromKey( + $sha1, array( 'time' => $time ) ); + } else { // get by (name,timestamp) + $img = wfFindFile( $nt, array( 'time' => $time ) ); + } + } } else { $img = false; } @@ -353,7 +365,6 @@ class ImageGallery . $textlink . $text . $nb . "\n\t\t\t" . "\n\t\t"; - ++$i; } $s .= "\n"; -- 2.20.1