Replace deprecated Language::fetchLanguageName

Bug: T325962
Change-Id: Ib8bba98d88b55c9e9b4d31dcc877d28c0d1304bb
This commit is contained in:
Umherirrender 2022-12-27 17:18:50 +01:00
parent 1cfcab778b
commit d65018980f
2 changed files with 6 additions and 7 deletions

View file

@ -3,7 +3,6 @@
namespace MediaWiki\Extension\Interwiki;
use Hooks as MWHooks;
use Language;
use MediaWiki\MediaWikiServices;
use WikiMap;
@ -60,7 +59,7 @@ class Hooks {
public static function onInterwikiLoadPrefix( $prefix, &$iwData ) {
global $wgInterwikiCentralDB, $wgInterwikiCentralInterlanguageDB;
$isInterlanguageLink = Language::fetchLanguageName( $prefix );
$isInterlanguageLink = MediaWikiServices::getInstance()->getLanguageNameUtils()->getLanguageName( $prefix );
if ( !$isInterlanguageLink && !self::$shouldSkipIWCheck ) {
// Check if prefix exists locally and skip
$lookup = MediaWikiServices::getInstance()->getInterwikiLookup();

View file

@ -4,7 +4,6 @@ namespace MediaWiki\Extension\Interwiki;
use Html;
use HTMLForm;
use Language;
use LogPage;
use MediaWiki\MediaWikiServices;
use OutputPage;
@ -252,7 +251,7 @@ class SpecialInterwiki extends SpecialPage {
// Disallow adding local interlanguage definitions if using global
$interwikiCentralInterlanguageDB = $config->get( 'InterwikiCentralInterlanguageDB' );
if (
$do === 'add' && Language::fetchLanguageName( $prefix )
$do === 'add' && MediaWikiServices::getInstance()->getLanguageNameUtils()->getLanguageName( $prefix )
&& $interwikiCentralInterlanguageDB !== WikiMap::getCurrentWikiId()
&& $interwikiCentralInterlanguageDB !== null
) {
@ -352,6 +351,7 @@ class SpecialInterwiki extends SpecialPage {
$iwGlobalLanguagePrefixes = [];
$config = $this->getConfig();
$interwikiCentralDB = $config->get( 'InterwikiCentralDB' );
$languageNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils();
if ( $interwikiCentralDB !== null && $interwikiCentralDB !== WikiMap::getCurrentWikiId() ) {
// Fetch list from global table
$dbrCentralDB = wfGetDB( DB_REPLICA, [], $interwikiCentralDB );
@ -359,7 +359,7 @@ class SpecialInterwiki extends SpecialPage {
$retval = [];
foreach ( $res as $row ) {
$row = (array)$row;
if ( !Language::fetchLanguageName( $row['iw_prefix'] ) ) {
if ( !$languageNameUtils->getLanguageName( $row['iw_prefix'] ) ) {
$retval[] = $row;
}
}
@ -381,7 +381,7 @@ class SpecialInterwiki extends SpecialPage {
$row = (array)$row;
// Note that the above DB query explicitly *excludes* interlang ones
// (which makes sense), whereas here we _only_ care about interlang ones!
if ( Language::fetchLanguageName( $row['iw_prefix'] ) ) {
if ( $languageNameUtils->getLanguageName( $row['iw_prefix'] ) ) {
$retval2[] = $row;
}
}
@ -392,7 +392,7 @@ class SpecialInterwiki extends SpecialPage {
$iwLocalPrefixes = [];
$iwLanguagePrefixes = [];
foreach ( $iwPrefixes as $iwPrefix ) {
if ( Language::fetchLanguageName( $iwPrefix['iw_prefix'] ) ) {
if ( $languageNameUtils->getLanguageName( $iwPrefix['iw_prefix'] ) ) {
$iwLanguagePrefixes[] = $iwPrefix;
} else {
$iwLocalPrefixes[] = $iwPrefix;