r84632 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84631‎ | r84632 | r84633 >
Date:21:21, 23 March 2011
Author:aaron
Status:ok
Tags:
Comment:
* Follow-up r84610: don't assume a Parser object is attached
* Removed unused $i var
Modified paths:
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImageGallery.php
@@ -247,7 +247,7 @@
248248 }
249249
250250 $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights );
251 - $i = 0;
 251+ # Output each image...
252252 foreach ( $this->mImages as $pair ) {
253253 $nt = $pair[0];
254254 $text = $pair[1]; # "text" means "caption" here
@@ -257,8 +257,20 @@
258258 $time = $sha1 = $descQuery = false;
259259 wfRunHooks( 'BeforeGalleryFindFile',
260260 array( &$this, &$nt, &$time, &$descQuery, &$sha1 ) );
261 - # Fetch and register the file (file title may be different via hooks)
262 - list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
 261+ # Get the file...
 262+ if ( $this->mParser instanceof Parser ) {
 263+ # Fetch and register the file (file title may be different via hooks)
 264+ list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 );
 265+ } else {
 266+ if ( $time === '0' ) {
 267+ $img = false; // broken thumbnail forced by hook
 268+ } elseif ( $sha1 ) { // get by (sha1,timestamp)
 269+ $img = RepoGroup::singleton()->findFileFromKey(
 270+ $sha1, array( 'time' => $time ) );
 271+ } else { // get by (name,timestamp)
 272+ $img = wfFindFile( $nt, array( 'time' => $time ) );
 273+ }
 274+ }
263275 } else {
264276 $img = false;
265277 }
@@ -353,7 +365,6 @@
354366 . $textlink . $text . $nb
355367 . "\n\t\t\t</div>"
356368 . "\n\t\t</div></li>";
357 - ++$i;
358369 }
359370 $s .= "\n</ul>";
360371

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84610* Put parser output file version tracking to core...aaron17:35, 23 March 2011

Status & tagging log