Skip to content

Commit

Permalink
MessageCache: Let extensions signal that a particular key cannot exis…
Browse files Browse the repository at this point in the history
…t in DB

Workaround T193271 performance regression by letting extensions signal that a
particular message key cannot exist in the DB. This allows us to use a
MessageCache::get hook handler to dynamically handle problematic keys in one
place (MessageCachePerformance extension) without patching core, while
maintaining compatibility with conditional message lookups that trigger fallback
logic depending on the outcome of a Message::exists() existence check.
  • Loading branch information
mszabo-wikia authored and Michał Prochowski committed Dec 2, 2022
1 parent 0c8d94e commit 026bf08
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/language/MessageCache.php
Expand Up @@ -993,7 +993,11 @@ public function get( $key, $useDB = true, $langcode = true ) {
// Normalise title-case input (with some inlining)
$lckey = self::normalizeKey( $key );

$this->hookRunner->onMessageCache__get( $lckey );
// Fandom change: Workaround T193271 performance regression by letting extensions signal
// that a particular message key cannot exist in the database
if ( !$this->hookRunner->onMessageCache__get( $lckey ) ) {
return false;
}

// Loop through each language in the fallback list until we find something useful
$message = $this->getMessageFromFallbackChain(
Expand Down

0 comments on commit 026bf08

Please sign in to comment.