From: Aaron Schulz Date: Wed, 23 Mar 2011 21:21:31 +0000 (+0000) Subject: * Follow-up r84610: don't assume a Parser object is attached X-Git-Tag: 1.31.0-rc.0~31227 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=a90c8f87b2e7c2d26d148b1d2679e02441539291;p=lhc%2Fweb%2Fwiklou.git * Follow-up r84610: don't assume a Parser object is attached * Removed unused $i var --- 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";