From: Brian Wolff Date: Wed, 7 Aug 2013 20:26:52 +0000 (-0300) Subject: More rigorous clearing of image redirect cache X-Git-Tag: 1.31.0-rc.0~19007^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=ac174f80ac4468d3767d1afec6e7afc1cd0e1cf8;p=lhc%2Fweb%2Fwiklou.git More rigorous clearing of image redirect cache Instead of deleting the cache key, set a temporary value, so that the key stays "deleted" long enough so that replag won't cause the key to be repopulated with an incorrect value from a slave db. Bug: 52200 Change-Id: I0941c93b76fb0aa8eedb883a3ed1167c6e14d0c0 --- diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 549be40807..9b62243b7c 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -171,13 +171,13 @@ class LocalRepo extends FileRepo { if ( $cachedValue === ' ' || $cachedValue === '' ) { // Does not exist return false; - } elseif ( strval( $cachedValue ) !== '' ) { + } elseif ( strval( $cachedValue ) !== '' && $cachedValue !== ' PURGED' ) { return Title::newFromText( $cachedValue, NS_FILE ); } // else $cachedValue is false or null: cache miss $id = $this->getArticleID( $title ); if ( !$id ) { - $wgMemc->set( $memcKey, " ", $expiry ); + $wgMemc->add( $memcKey, " ", $expiry ); return false; } $dbr = $this->getSlaveDB(); @@ -190,10 +190,10 @@ class LocalRepo extends FileRepo { if ( $row && $row->rd_namespace == NS_FILE ) { $targetTitle = Title::makeTitle( $row->rd_namespace, $row->rd_title ); - $wgMemc->set( $memcKey, $targetTitle->getDBkey(), $expiry ); + $wgMemc->add( $memcKey, $targetTitle->getDBkey(), $expiry ); return $targetTitle; } else { - $wgMemc->set( $memcKey, '', $expiry ); + $wgMemc->add( $memcKey, '', $expiry ); return false; } } @@ -347,7 +347,11 @@ class LocalRepo extends FileRepo { global $wgMemc; $memcKey = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) ); if ( $memcKey ) { - $wgMemc->delete( $memcKey ); + // Set a temporary value for the cache key, to ensure + // that this value stays purged long enough so that + // it isn't refreshed with a stale value due to a + // lagged slave. + $wgMemc->set( $memcKey, ' PURGED', 12 ); } } } diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 0e342cc0bb..1dc4244eb8 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -692,13 +692,6 @@ class MovePageForm extends UnlistedSpecialPage { # Deal with watches (we don't watch subpages) WatchAction::doWatchOrUnwatch( $this->watch, $ot, $user ); WatchAction::doWatchOrUnwatch( $this->watch, $nt, $user ); - - # Re-clear the file redirect cache, which may have been polluted by - # parsing in messages above. See CR r56745. - # @todo FIXME: Needs a more robust solution inside FileRepo. - if ( $ot->getNamespace() == NS_FILE ) { - RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $ot ); - } } function showLogFragment( $title ) {