Stop stubbing StubUserLang
authorChad Horohoe <chadh@wikimedia.org>
Tue, 3 Oct 2017 21:26:18 +0000 (14:26 -0700)
committerChad <chadh@wikimedia.org>
Tue, 3 Oct 2017 21:54:34 +0000 (21:54 +0000)
Stub objects are confusing as heck and are a performance optimization
that really aren't fit for the modern era. They were designed to avoid
loading the actual code from the disk back in the days when bytecode
caching wasn't always gonna be there.

It's 2017. If you're using HHVM, you've got a bytecode cache. If you're
using any reasonably recent version of PHP then you've got the opcode
caching enabled by default in basically every distro-related build.

Nothing actually relies on this object being a stub (that'd be silly),
so only references are basically things force unstubbing (also kind of
silly) the object. Once remaining code referencing this in extensions
are all cleaned up then we can remove the class itself.

Change-Id: I15df24aeeb729e8e764792daa933377f35042fab

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

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