From 2d52e36018ea477db76e36026029e75f4c0b5c16 Mon Sep 17 00:00:00 2001 From: Florian Schmidt Date: Tue, 4 Oct 2016 17:40:35 +0200 Subject: [PATCH] Don't use Config as an access method for global objects The Config interface (and it's implementation(s)) was never thought to be an access method for objects saved in the global state, even if it works with the current implementation GlobalVarConfig. Imagine, that MediaWiki core switches to another file-based configuratiion storage or a a database based one, we wouldn't be able to provide access to global objects anymore, without weird hacks in the new config-backend implementation or serializing objects to store in the database or something else. This all isn't the idea with the Config interface, as far as I know, so don't use it at all. This commit changes the access to wgContLang to use the global keyword, instead of accessing it through Config. Follow up: Ice4f40911c3761c2542430935bc1898bc4e7a4d4 Follow up: I46f376a82205a5c99b98c9e971f9e9d7868ce9fb Change-Id: I7a08b3bb649898abd445317a523051b07420b211 --- includes/OutputPage.php | 4 +++- includes/cache/HTMLFileCache.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b2e7d94337..a69c0e6692 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2215,6 +2215,8 @@ class OutputPage extends ContextSource { * @throws MWException */ public function output( $return = false ) { + global $wgContLang; + if ( $this->mDoNothing ) { return $return ? '' : null; } @@ -2261,7 +2263,7 @@ class OutputPage extends ContextSource { ob_start(); $response->header( 'Content-type: ' . $config->get( 'MimeType' ) . '; charset=UTF-8' ); - $response->header( 'Content-language: ' . $config->get( 'ContLang' )->getHtmlCode() ); + $response->header( 'Content-language: ' . $wgContLang->getHtmlCode() ); // Avoid Internet Explorer "compatibility view" in IE 8-10, so that // jQuery etc. can work correctly. diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php index 060837ecdf..ae8efa9c82 100644 --- a/includes/cache/HTMLFileCache.php +++ b/includes/cache/HTMLFileCache.php @@ -157,6 +157,7 @@ class HTMLFileCache extends FileCacheBase { * @return void */ public function loadFromFileCache( IContextSource $context, $mode = self::MODE_NORMAL ) { + global $wgContLang; $config = MediaWikiServices::getInstance()->getMainConfig(); wfDebug( __METHOD__ . "()\n" ); @@ -167,10 +168,9 @@ class HTMLFileCache extends FileCacheBase { $context->getTitle()->resetArticleID( 0 ); } - $contLang = $config->get( 'ContLang' ); $context->getOutput()->sendCacheControl(); header( "Content-Type: {$config->get( 'MimeType' )}; charset=UTF-8" ); - header( "Content-Language: {$contLang->getHtmlCode()}" ); + header( "Content-Language: {$wgContLang->getHtmlCode()}" ); if ( $this->useGzip() ) { if ( wfClientAcceptsGzip() ) { header( 'Content-Encoding: gzip' ); -- 2.20.1