From: Timo Tijhof Date: Sun, 22 Jul 2018 23:52:41 +0000 (+0100) Subject: cache: Minor docs for MessageCache interaction with WANObjectCache X-Git-Tag: 1.34.0-rc.0~4666^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=c9bcbaa558e6a398e7e61ab82d3eb07ca69d6ea7;p=lhc%2Fweb%2Fwiklou.git cache: Minor docs for MessageCache interaction with WANObjectCache Follows-up 04bc03a29a. Change-Id: I8fb810fc2e08277bb64fa18595483a2161cfb1cc --- 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; } ); }