Merge "Add a hook into LanguageConverter#getPreferredVariant() to allow extensions...
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 23 Jan 2018 23:01:34 +0000 (23:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 23 Jan 2018 23:01:34 +0000 (23:01 +0000)
docs/hooks.txt
languages/LanguageConverter.php

index d497884..7084b51 100644 (file)
@@ -1666,6 +1666,13 @@ $query: query options passed to Title::getInternalURL()
 'GetIP': modify the ip of the current user (called only once).
 &$ip: string holding the ip as determined so far
 
+'GetLangPreferredVariant': Called in LanguageConverter#getPreferredVariant() to
+  allow fetching the language variant code from cookies or other such
+  alternative storage.
+&$req: language variant from the URL (string) or boolean false if no variant
+  was specified in the URL; the value of this variable comes from
+  LanguageConverter#getURLVariant()
+
 'GetLinkColours': modify the CSS class of an array of page links.
 $linkcolour_ids: array of prefixed DB keys of the pages linked to,
   indexed by page_id.
index f9631a1..f611358 100644 (file)
@@ -163,6 +163,8 @@ class LanguageConverter {
 
                $req = $this->getURLVariant();
 
+               Hooks::run( 'GetLangPreferredVariant', [ &$req ] );
+
                if ( $wgUser->isSafeToLoad() && $wgUser->isLoggedIn() && !$req ) {
                        $req = $this->getUserVariant();
                } elseif ( !$req ) {