From 8423c127fcd014bdef3b20761cd557303b135d66 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 6 Jul 2019 00:08:39 -0700 Subject: [PATCH] Move the showMissingArticle() cache from $wgMainStash to "db-replicated" Bug: T227376 Change-Id: Ice3b3b1bc8a09f66c4f02bb233a1992ed6d46ab7 --- includes/page/Article.php | 6 +++--- includes/page/WikiPage.php | 6 +++--- tests/common/TestSetup.php | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/page/Article.php b/includes/page/Article.php index aa38d1f787..4e280851d8 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1400,11 +1400,11 @@ class Article implements Page { # Show delete and move logs if there were any such events. # The logging query can DOS the site when bots/crawlers cause 404 floods, # so be careful showing this. 404 pages must be cheap as they are hard to cache. - $cache = $services->getMainObjectStash(); - $key = $cache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) ); + $dbCache = ObjectCache::getInstance( 'db-replicated' ); + $key = $dbCache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) ); $loggedIn = $this->getContext()->getUser()->isLoggedIn(); $sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent(); - if ( $loggedIn || $cache->get( $key ) || $sessionExists ) { + if ( $loggedIn || $dbCache->get( $key ) || $sessionExists ) { $logTypes = [ 'delete', 'move', 'protect' ]; $dbr = wfGetDB( DB_REPLICA ); diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index fa01ce49a6..af1781a042 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2811,9 +2811,9 @@ class WikiPage implements Page, IDBAccessObject { $status->value = $logid; // Show log excerpt on 404 pages rather than just a link - $cache = MediaWikiServices::getInstance()->getMainObjectStash(); - $key = $cache->makeKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) ); - $cache->set( $key, 1, $cache::TTL_DAY ); + $dbCache = ObjectCache::getInstance( 'db-replicated' ); + $key = $dbCache->makeKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) ); + $dbCache->set( $key, 1, $dbCache::TTL_DAY ); } return $status; diff --git a/tests/common/TestSetup.php b/tests/common/TestSetup.php index a42f573bb3..d4df8ae5ee 100644 --- a/tests/common/TestSetup.php +++ b/tests/common/TestSetup.php @@ -11,6 +11,7 @@ class TestSetup { public static function applyInitialConfig() { global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgMainWANCache; global $wgMainStash; + global $wgObjectCaches; global $wgLanguageConverterCacheType, $wgUseDatabaseMessages; global $wgLocaltimezone, $wgLocalisationCacheConf; global $wgSearchType; @@ -40,6 +41,8 @@ class TestSetup { $wgLanguageConverterCacheType = 'hash'; // Uses db-replicated in DefaultSettings $wgMainStash = 'hash'; + // Use hash instead of db + $wgObjectCaches['db-replicated'] = $wgObjectCaches['hash']; // Use memory job queue $wgJobTypeConf = [ 'default' => [ 'class' => JobQueueMemory::class, 'order' => 'fifo' ], -- 2.20.1