From c9bcbaa558e6a398e7e61ab82d3eb07ca69d6ea7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 23 Jul 2018 00:52:41 +0100 Subject: [PATCH] cache: Minor docs for MessageCache interaction with WANObjectCache Follows-up 04bc03a29a. Change-Id: I8fb810fc2e08277bb64fa18595483a2161cfb1cc --- includes/cache/MessageCache.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 59486e46d1..48aac7ea32 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -592,13 +592,15 @@ class MessageCache { [ 'title' => $title, 'code' => $code ] ); return; } - // Load the messages from the master DB to avoid race conditions + // Reload messages from the database and pre-populate dc-local caches + // as optimisation. Use the master DB to avoid race conditions. $cache = $this->loadFromDB( $code, self::FOR_UPDATE ); // Check if an individual cache key should exist and update cache accordingly $page = WikiPage::factory( Title::makeTitle( NS_MEDIAWIKI, $title ) ); $page->loadPageData( $page::READ_LATEST ); $text = $this->getMessageTextFromContent( $page->getContent() ); if ( is_string( $text ) && strlen( $text ) > $wgMaxMsgCacheEntrySize ) { + // Match logic of loadCachedMessagePageEntry() $this->wanCache->set( $this->bigMessageCacheKey( $cache['HASH'], $title ), ' ' . $text, @@ -1037,6 +1039,8 @@ class MessageCache { $title = Title::makeTitle( NS_MEDIAWIKI, $dbKey ); $revision = Revision::newKnownCurrent( $dbr, $title ); if ( !$revision ) { + // The wiki doesn't have a local override page. Cache absence with normal TTL. + // When overrides are created, self::replace() takes care of the cache. return '!NONEXISTENT'; } $content = $revision->getContent(); @@ -1050,13 +1054,14 @@ class MessageCache { $message = null; } - if ( is_string( $message ) ) { - return ' ' . $message; + if ( !is_string( $message ) ) { + // Revision failed to load Content, or Content is incompatible with wikitext. + // Possibly a temporary loading failure. + $ttl = 5; + return '!NONEXISTENT'; } - $ttl = 5; // possibly a temporary loading failure - - return '!NONEXISTENT'; + return ' ' . $message; } ); } -- 2.20.1