From 7ab57ba290f670847f981d5fc2c79339f1d4844e Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 3 Oct 2017 14:26:18 -0700 Subject: [PATCH] Stop stubbing StubUserLang 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 | 2 -- includes/Setup.php | 2 +- includes/Status.php | 7 ++----- includes/parser/CoreParserFunctions.php | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/includes/Message.php b/includes/Message.php index 0240fa7477..d119940adf 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -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 " diff --git a/includes/Setup.php b/includes/Setup.php index 68e3d96afe..0be5c6e930 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -811,7 +811,7 @@ $wgUser = RequestContext::getMain()->getUser(); // BackCompat /** * @var Language $wgLang */ -$wgLang = new StubUserLang; +$wgLang = RequestContext::getMain()->getLanguage(); // BackCompat /** * @var OutputPage $wgOut diff --git a/includes/Status.php b/includes/Status.php index a35af6e8c6..5456ed06e3 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -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 ); diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 3d262628be..bebf3f8a0b 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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 ) { -- 2.20.1