Linker: Use RequestContext::getMain()->getLanguage() instead of $wgLang
authorFomafix <fomafix@googlemail.com>
Tue, 16 Oct 2018 09:46:24 +0000 (11:46 +0200)
committerFomafix <fomafix@googlemail.com>
Fri, 21 Dec 2018 16:41:30 +0000 (17:41 +0100)
$wgLang can be an StubUserLang object. This change allows to force a
Language object.

Change-Id: I93c79b985a2ee49648c678844eef189126a4d765

includes/Linker.php

index b605acd..947ad6d 100644 (file)
@@ -1580,9 +1580,8 @@ class Linker {
         * @return string Full html of the TOC
         */
        public static function tocList( $toc, $lang = null ) {
-               global $wgLang;
-               $lang = $lang ?? $wgLang;
-               if ( !is_object( $lang ) ) {
+               $lang = $lang ?? RequestContext::getMain()->getLanguage();
+               if ( !$lang instanceof Language ) {
                        wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' );
                        $lang = wfGetLangObj( $lang );
                }