From ac174f80ac4468d3767d1afec6e7afc1cd0e1cf8 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Wed, 7 Aug 2013 17:26:52 -0300 Subject: [PATCH] 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 --- includes/filerepo/LocalRepo.php | 14 +++++++++----- includes/specials/SpecialMovepage.php | 7 ------- 2 files changed, 9 insertions(+), 12 deletions(-) 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 ) { -- 2.20.1