Revert "Stop stubbing StubUserLang"
authorAddshore <addshorewiki@gmail.com>
Thu, 5 Oct 2017 16:51:11 +0000 (16:51 +0000)
committerAddshore <addshorewiki@gmail.com>
Thu, 5 Oct 2017 16:52:49 +0000 (16:52 +0000)
This reverts commit 7ab57ba290f670847f981d5fc2c79339f1d4844e.

Bug: T177478
Change-Id: I28ac95ebcb64231a12c178165a0cb174e70f4e18

includes/Message.php
includes/Setup.php
includes/Status.php
includes/parser/CoreParserFunctions.php

index d119940..0240fa7 100644 (file)
@@ -732,6 +732,8 @@ class Message implements MessageSpecifier, Serializable {
                        if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
                                $this->language = Language::factory( $lang );
                        }
+               } elseif ( $lang instanceof StubUserLang ) {
+                       $this->language = false;
                } else {
                        $type = gettype( $lang );
                        throw new MWException( __METHOD__ . " must be "
index 0be5c6e..68e3d96 100644 (file)
@@ -811,7 +811,7 @@ $wgUser = RequestContext::getMain()->getUser(); // BackCompat
 /**
  * @var Language $wgLang
  */
-$wgLang = RequestContext::getMain()->getLanguage(); // BackCompat
+$wgLang = new StubUserLang;
 
 /**
  * @var OutputPage $wgOut
index 5456ed0..a35af6e 100644 (file)
@@ -153,9 +153,12 @@ class Status extends StatusValue {
         * @return Language
         */
        protected function languageFromParam( $lang ) {
+               global $wgLang;
+
                if ( $lang === null ) {
-                       return RequestContext::getMain()->getLanguage();
-               } elseif ( $lang instanceof Language ) {
+                       // @todo: Use RequestContext::getMain()->getLanguage() instead
+                       return $wgLang;
+               } elseif ( $lang instanceof Language || $lang instanceof StubUserLang ) {
                        return $lang;
                } else {
                        return Language::factory( $lang );
index bebf3f8..3d26262 100644 (file)
@@ -493,7 +493,7 @@ class CoreParserFunctions {
         *
         * @param int|float $num
         * @param string $raw
-        * @param Language $language
+        * @param Language|StubUserLang $language
         * @return string
         */
        public static function formatRaw( $num, $raw, $language ) {