X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Ftitle%2FNaiveImportTitleFactory.php;h=1a6ba72a809863035cf260846f9d0bcee1d3a392;hp=5cb6112014d59776b6a92d9591b5cab07b626449;hb=a3cd158d8433e41cbeb299f0e268dfef363b2afd;hpb=9bf44d08f938cc9a85dc647b8a00665d5bd01fb6 diff --git a/includes/title/NaiveImportTitleFactory.php b/includes/title/NaiveImportTitleFactory.php index 5cb6112014..1a6ba72a80 100644 --- a/includes/title/NaiveImportTitleFactory.php +++ b/includes/title/NaiveImportTitleFactory.php @@ -18,6 +18,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * A class to convert page titles on a foreign wiki (ForeignTitle objects) into * page titles on the local wiki (Title objects), using a default namespace @@ -39,21 +41,23 @@ class NaiveImportTitleFactory implements ImportTitleFactory { * @return Title|null */ public function createTitleFromForeignTitle( ForeignTitle $foreignTitle ) { - global $wgContLang; - if ( $foreignTitle->isNamespaceIdKnown() ) { $foreignNs = $foreignTitle->getNamespaceId(); // For built-in namespaces (0 <= ID < 100), we try to find a local NS with // the same namespace ID - if ( $foreignNs < 100 && MWNamespace::exists( $foreignNs ) ) { + if ( + $foreignNs < 100 && + MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $foreignNs ) + ) { return Title::makeTitleSafe( $foreignNs, $foreignTitle->getText() ); } } // Do we have a local namespace by the same name as the foreign // namespace? - $targetNs = $wgContLang->getNsIndex( $foreignTitle->getNamespaceName() ); + $targetNs = MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( + $foreignTitle->getNamespaceName() ); if ( $targetNs !== false ) { return Title::makeTitleSafe( $targetNs, $foreignTitle->getText() ); }