From 5b342c51ab384d5d5a3c81a5bc3b378f4b950db8 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Sun, 1 Sep 2019 14:59:59 +0100 Subject: [PATCH] Avoid usage of deprecated $wgContLang global (dep in 1.32) Change-Id: Ic70ac2bc7eeba6af9a69bb1eb839a87cd06c01f8 --- .phpcs.xml | 1 - includes/ApiCategoryTree.php | 4 ++-- includes/CategoryTree.php | 12 ++++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index ef529066..b0464c31 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,7 +1,6 @@ - . diff --git a/includes/ApiCategoryTree.php b/includes/ApiCategoryTree.php index 42dbb467..64fed012 100644 --- a/includes/ApiCategoryTree.php +++ b/includes/ApiCategoryTree.php @@ -80,14 +80,14 @@ class ApiCategoryTree extends ApiBase { * @return string HTML */ private function getHTML( CategoryTree $ct, Title $title, $depth, Config $ctConfig ) { - global $wgContLang, $wgMemc; + global $wgMemc; $mckey = ObjectCache::getLocalClusterInstance()->makeKey( 'ajax-categorytree', md5( $title->getDBkey() ), md5( $ct->getOptionsAsCacheKey( $depth ) ), $this->getLanguage()->getCode(), - $wgContLang->getExtraHashOptions(), + MediaWikiServices::getInstance()->getContentLanguage()->getExtraHashOptions(), $ctConfig->get( 'RenderHashAppend' ) ); diff --git a/includes/CategoryTree.php b/includes/CategoryTree.php index c6ddd266..125a6cea 100644 --- a/includes/CategoryTree.php +++ b/includes/CategoryTree.php @@ -94,8 +94,6 @@ class CategoryTree { * @return array|bool */ private static function decodeNamespaces( $nn ) { - global $wgContLang; - if ( $nn === false || is_null( $nn ) ) { return false; } @@ -105,7 +103,7 @@ class CategoryTree { } $namespaces = []; - + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); foreach ( $nn as $n ) { if ( is_int( $n ) ) { $ns = $n; @@ -122,7 +120,7 @@ class CategoryTree { } elseif ( $n == '-' || $n == '_' || $n == '*' || $lower == 'main' ) { $ns = NS_MAIN; } else { - $ns = $wgContLang->getNsIndex( $n ); + $ns = $contLang->getNsIndex( $n ); } } @@ -697,8 +695,6 @@ class CategoryTree { public static function createCountString( IContextSource $context, Category $cat = null, $countMode ) { - global $wgContLang; - # Get counts, with conversion to integer so === works # Note: $allCount is the total number of cat members, # not the count of how many members are normal pages. @@ -713,8 +709,8 @@ class CategoryTree { # numbers and commas get messed up in a mixed dir env 'dir' => $context->getLanguage()->getDir() ]; - - $s = $wgContLang->getDirMark() . ' '; + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + $s = $contLang->getDirMark() . ' '; # Create a list of category members with only non-zero member counts $memberNums = [];