Pass the language code to the MessagesPreLoad hook
authorJack Phoenix <jack@countervandalism.net>
Sun, 8 Jan 2017 00:34:22 +0000 (02:34 +0200)
committerJack Phoenix <jack@countervandalism.net>
Sun, 8 Jan 2017 00:34:22 +0000 (02:34 +0200)
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
includes/cache/MessageCache.php

index 1da39cf..acfd217 100644 (file)
@@ -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.
index 0aca213..352a94c 100644 (file)
@@ -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;
                        }