r84618 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84617‎ | r84618 | r84619 >
Date:18:23, 23 March 2011
Author:aaron
Status:ok
Tags:
Comment:
Straighten out dependency handling from r84610 (files) and before (templates)
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3361,7 +3361,10 @@
33623362 );
33633363 break;
33643364 }
3365 - $rev = $id ? Revision::newFromId( $id ) : Revision::newFromTitle( $title );
 3365+ # Get the revision
 3366+ $rev = $id
 3367+ ? Revision::newFromId( $id )
 3368+ : Revision::newFromTitle( $title );
33663369 $rev_id = $rev ? $rev->getId() : 0;
33673370 # If there is no current revision, there is no page
33683371 if ( $id === false && !$rev ) {
@@ -3373,6 +3376,13 @@
33743377 'title' => $title,
33753378 'page_id' => $title->getArticleID(),
33763379 'rev_id' => $rev_id );
 3380+ if ( $rev && !$title->equals( $rev->getTitle() ) ) {
 3381+ # We fetched a rev from a different title; register it too...
 3382+ $deps[] = array(
 3383+ 'title' => $rev->getTitle(),
 3384+ 'page_id' => $rev->getPage(),
 3385+ 'rev_id' => $rev_id );
 3386+ }
33773387
33783388 if ( $rev ) {
33793389 $text = $rev->getText();
@@ -3417,24 +3427,26 @@
34183428 * @param Title $title
34193429 * @param string $time MW timestamp
34203430 * @param string $sha1 base 36 SHA-1
3421 - * @return Array ( File or false, Title )
 3431+ * @return Array ( File or false, Title of file )
34223432 */
34233433 function fetchFileAndTitle( $title, $time = false, $sha1 = false ) {
34243434 if ( $time === '0' ) {
34253435 $file = false; // broken thumbnail forced by hook
34263436 } elseif ( $sha1 ) { // get by (sha1,timestamp)
34273437 $file = RepoGroup::singleton()->findFileFromKey( $sha1, array( 'time' => $time ) );
3428 - if ( $file ) {
3429 - $title = $file->getTitle(); // file title may not match $title
3430 - }
34313438 } else { // get by (name,timestamp)
34323439 $file = wfFindFile( $title, array( 'time' => $time ) );
34333440 }
3434 - # Register the file as a dependancy
34353441 $time = $file ? $file->getTimestamp() : null;
34363442 $sha1 = $file ? $file->getSha1() : null;
 3443+ # Register the file as a dependency...
34373444 $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
3438 -
 3445+ if ( $file && !$title->equals( $file->getTitle() ) ) {
 3446+ # We fetched a rev from a different title; register it too...
 3447+ $this->mOutput->addImage( $file->getTitle()->getDBkey(), $time, $sha1 );
 3448+ # Update fetched file title
 3449+ $title = $file->getTitle();
 3450+ }
34393451 return array( $file, $title );
34403452 }
34413453

Sign-offs

UserFlagDate
😂inspected14:04, 15 July 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r91785Follow-up r88054: register the file if a hook changed the target file.btongminh10:31, 9 July 2011

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