From bdddfb92ba9f75241daaf60f2dc37486c2a665cd Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Fri, 8 May 2020 11:11:23 -0700 Subject: [PATCH] Drop wgContLang, deprecated in 1.32 Bug: T245940 Depends-On: Ib7fe7318100c0aadc3aa759416bf787913a9b788 Change-Id: I75c3b6715abd5eaf3619337cab8b1844e9a8349a --- .phpcs.xml | 1 - RELEASE-NOTES-1.36 | 2 ++ docs/globals.txt | 3 --- includes/Setup.php | 16 +++++++--------- includes/installer/CliInstaller.php | 6 +++--- includes/installer/WebInstaller.php | 3 +-- tests/parser/ParserTestRunner.php | 3 --- tests/phpunit/MediaWikiIntegrationTestCase.php | 7 +++---- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index cfc1a1b84a2..cfe93552ec4 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -16,7 +16,6 @@ - diff --git a/RELEASE-NOTES-1.36 b/RELEASE-NOTES-1.36 index 24f118050ea..1c538163857 100644 --- a/RELEASE-NOTES-1.36 +++ b/RELEASE-NOTES-1.36 @@ -400,6 +400,8 @@ because of Phabricator reports. * Command::execute() now returns a Shellbox\Command\UnboxedResult instead of a MediaWiki\Shell\Result. Any type hints should be updated. * ObjectCache::detectLocalServerCache(), deprecated in 1.35, was removed. +* The $wgContLang variable, deprecated in 1.32, was removed. You can instead use + MediaWikiServices::getInstance()->getContentLanguage(). * … === Deprecations in 1.36 === diff --git a/docs/globals.txt b/docs/globals.txt index fecec1f357b..73e8d2dde01 100644 --- a/docs/globals.txt +++ b/docs/globals.txt @@ -52,9 +52,6 @@ $wgUser $wgLang Language object selected by user preferences. -$wgContLang - Language object associated with the wiki being viewed. - $wgParser Parser object. Parser extensions used to register their hooks here; modern code should use the ParserFirstCallInit hook. diff --git a/includes/Setup.php b/includes/Setup.php index 1deb16c7c03..1582fee516a 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -695,12 +695,6 @@ if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) { // Most of the config is out, some might want to run hooks here. Hooks::runner()->onSetupAfterCache(); -/** - * @var Language $wgContLang - * @deprecated since 1.32, use the ContentLanguage service directly - */ -$wgContLang = MediaWikiServices::getInstance()->getContentLanguage(); - // Now that variant lists may be available... $wgRequest->interpolateTitle(); @@ -723,6 +717,8 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { ); } + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + // Initialize the session try { $session = MediaWiki\Session\SessionManager::getGlobalSession(); @@ -731,14 +727,16 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { // sessions tied for top priority. Report this to the user. $list = []; foreach ( $ex->getSessionInfos() as $info ) { - $list[] = $info->getProvider()->describe( $wgContLang ); + $list[] = $info->getProvider()->describe( $contLang ); } - $list = $wgContLang->listToText( $list ); + $list = $contLang->listToText( $list ); throw new HttpError( 400, - Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $wgContLang ) + Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $contLang ) ); } + unset( $contLang ); + if ( $session->isPersistent() ) { $wgInitialSessionId = $session->getSessionId(); } diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index adcfc59c8f9..4398db8324f 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -55,7 +55,7 @@ class CliInstaller extends Installer { * @throws InstallException */ public function __construct( $siteName, $admin = null, array $options = [] ) { - global $wgContLang, $wgPasswordPolicy; + global $wgPasswordPolicy; parent::__construct(); @@ -75,7 +75,6 @@ class CliInstaller extends Installer { $this->setVar( '_UserLang', $options['lang'] ); $wgLanguageCode = $options['lang']; $this->setVar( 'wgLanguageCode', $wgLanguageCode ); - $wgContLang = MediaWikiServices::getInstance()->getContentLanguage(); $wgLang = MediaWikiServices::getInstance()->getLanguageFactory() ->getLanguage( $options['lang'] ); RequestContext::getMain()->setLanguage( $wgLang ); @@ -83,7 +82,8 @@ class CliInstaller extends Installer { $this->setVar( 'wgSitename', $siteName ); - $metaNS = $wgContLang->ucfirst( str_replace( ' ', '_', $siteName ) ); + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + $metaNS = $contLang->ucfirst( str_replace( ' ', '_', $siteName ) ); if ( $metaNS == 'MediaWiki' ) { $metaNS = 'Project'; } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 460c78fd0bc..813010db2a3 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -499,7 +499,7 @@ class WebInstaller extends Installer { * Initializes language-related variables. */ public function setupLanguage() { - global $wgLang, $wgContLang, $wgLanguageCode; + global $wgLang, $wgLanguageCode; if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) { $wgLanguageCode = $this->getAcceptLanguage(); @@ -511,7 +511,6 @@ class WebInstaller extends Installer { } else { $wgLanguageCode = $this->getVar( 'wgLanguageCode' ); } - $wgContLang = MediaWikiServices::getInstance()->getContentLanguage(); } /** diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 5daf6c4b112..2516131d39e 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1251,7 +1251,6 @@ class ParserTestRunner { // In addition the ParserFactory needs to be recreated as well. $lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langCode ); $lang->resetNamespaces(); - $setup['wgContLang'] = $lang; $setup[] = static function () use ( $lang ) { MediaWikiServices::getInstance()->disableService( 'ContentLanguage' ); MediaWikiServices::getInstance()->redefineService( @@ -1310,7 +1309,6 @@ class ParserTestRunner { // Reset context to the restored globals $context->setUser( $GLOBALS['wgUser'] ); - $context->setLanguage( $GLOBALS['wgContLang'] ); $context->setSkin( $oldSkin ); $context->setOutput( $GLOBALS['wgOut'] ); }; @@ -1707,7 +1705,6 @@ class ParserTestRunner { if ( $services->getContentLanguage()->getCode() !== 'en' ) { $setup['wgLanguageCode'] = 'en'; $lang = $services->getLanguageFactory()->getLanguage( 'en' ); - $setup['wgContLang'] = $lang; $setup[] = static function () use ( $lang ) { $services = MediaWikiServices::getInstance(); $services->disableService( 'ContentLanguage' ); diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index e512930fb51..a9bf92f6782 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -1131,19 +1131,18 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { } /** - * Replace legacy globals like $wgParser and $wgContLang with fresh ones so they pick up any - * config changes. They're deprecated, but we still support them for now. + * Replace legacy global $wgParser with a fresh one so it picks up any + * config changes. It's deprecated, but we still support it for now. */ private static function resetLegacyGlobals() { // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgParser - global $wgParser, $wgContLang; + global $wgParser; // We don't have to replace the parser if it wasn't unstubbed if ( !( $wgParser instanceof StubObject ) ) { $wgParser = new StubObject( 'wgParser', static function () { return MediaWikiServices::getInstance()->getParser(); } ); } - $wgContLang = MediaWikiServices::getInstance()->getContentLanguage(); } /**