From ce1047c0b536a70f0fead5e9c5c28db7b096297b Mon Sep 17 00:00:00 2001 From: Andrew Green Date: Tue, 19 Mar 2019 16:16:11 -0600 Subject: [PATCH] Improve Caching in Title::loadRestrictions() Change-Id: I9a7edf6fc7d0bb0f4129fe13323964e9fae791f3 --- includes/Title.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/Title.php b/includes/Title.php index 88a7efb8df..2e43b8dfc7 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3342,12 +3342,17 @@ class Title implements LinkTarget, IDBAccessObject { $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); $rows = $cache->getWithSetCallback( // Page protections always leave a new null revision - $cache->makeKey( 'page-restrictions', $id, $this->getLatestRevID() ), + $cache->makeKey( 'page-restrictions-v1', $id, $this->getLatestRevID() ), $cache::TTL_DAY, function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) { $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + if ( $lb->hasOrMadeRecentMasterChanges() ) { + // @TODO: cleanup Title cache and caller assumption mess in general + $ttl = WANObjectCache::TTL_UNCACHEABLE; + } return $loadRestrictionsFromDb( $dbr ); } -- 2.20.1