From 38c0e0410a24bfff30faf3d5865d784395089197 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Sun, 8 Jan 2017 02:34:22 +0200 Subject: [PATCH] Pass the language code to the MessagesPreLoad hook So that extensions like MessageCommons can try to use this (and $wgLanguageCode) instead of $wgLang->getCode()/$wgContLang->getCode(), as the latter ones cause fatals and recursion, at least with the Gadgets extension also enabled at the same time. Change-Id: If71fe1ded26c7a1c771128397783783ad5715b00 --- docs/hooks.txt | 1 + includes/cache/MessageCache.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 1da39cf61b..acfd217a7d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2231,6 +2231,7 @@ $text: new contents of the page. 'MessagesPreLoad': When loading a message from the database. $title: title of the message (string) &$message: value (string), change it to the message you want to define +$code: code (string) denoting the language to try. 'MimeMagicGuessFromContent': Allows MW extensions guess the MIME by content. $mimeMagic: Instance of MimeMagic. diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 0aca213a00..352a94c5fb 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -963,7 +963,7 @@ class MessageCache { } else { // XXX: This is not cached in process cache, should it? $message = false; - Hooks::run( 'MessagesPreLoad', [ $title, &$message ] ); + Hooks::run( 'MessagesPreLoad', [ $title, &$message, $code ] ); if ( $message !== false ) { return $message; } -- 2.20.1