r97767 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97766‎ | r97767 | r97768 >
Date:21:32, 21 September 2011
Author:aaron
Status:ok
Tags:
Comment:
Clear findFile() process cache of file moves (issue came up with bug bug 31056)
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/filerepo/RepoGroup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/RepoGroup.php
@@ -385,4 +385,19 @@
386386 unset( $this->cache[$key] );
387387 }
388388 }
 389+
 390+ /**
 391+ * Clear RepoGroup process cache used for finding a file
 392+ * @param $title Title|null Title of the file or null to clear all files
 393+ */
 394+ public function clearCache( Title $title = null ) {
 395+ if ( $title == null ) {
 396+ $this->cache = array();
 397+ } else {
 398+ $dbKey = $title->getDBkey();
 399+ if ( isset( $this->cache[$dbKey] ) ) {
 400+ unset( $this->cache[$dbKey] );
 401+ }
 402+ }
 403+ }
389404 }
Index: trunk/phase3/includes/Title.php
@@ -3168,8 +3168,8 @@
31693169 return $err;
31703170 }
31713171
3172 - // If it is a file, move it first. It is done before all other moving stuff is
3173 - // done because it's hard to revert
 3172+ // If it is a file, move it first.
 3173+ // It is done before all other moving stuff is done because it's hard to revert.
31743174 $dbw = wfGetDB( DB_MASTER );
31753175 if ( $this->getNamespace() == NS_FILE ) {
31763176 $file = wfLocalFile( $this );
@@ -3180,6 +3180,9 @@
31813181 }
31823182 }
31833183 }
 3184+ // Clear RepoGroup process cache
 3185+ RepoGroup::singleton()->clearCache( $this );
 3186+ RepoGroup::singleton()->clearCache( $nt ); # clear false negative cache
31843187
31853188 $dbw->begin(); # If $file was a LocalFile, its transaction would have closed our own.
31863189 $pageid = $this->getArticleID( self::GAID_FOR_UPDATE );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97701* Fixed bug causing new uploads to give "template/file changes need review" m...aaron07:13, 21 September 2011

Status & tagging log