X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Ftitle%2FNaiveForeignTitleFactory.php;h=307050b7ee9fdd321145202227fc076b469773e1;hb=4753b0a4ed4b6b8abb467c57323e5a075b48902b;hp=6c8bcc04e8fa912ff3063dda93cf20198854c8d7;hpb=19d0011d9c29906102cdfcb65f630d2fe7781f61;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/title/NaiveForeignTitleFactory.php b/includes/title/NaiveForeignTitleFactory.php index 6c8bcc04e8..307050b7ee 100644 --- a/includes/title/NaiveForeignTitleFactory.php +++ b/includes/title/NaiveForeignTitleFactory.php @@ -16,9 +16,10 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @license GPL 2+ */ +use MediaWiki\MediaWikiServices; + /** * A parser that translates page titles on a foreign wiki into ForeignTitle * objects, with no knowledge of the namespace setup on the foreign site. @@ -43,21 +44,22 @@ class NaiveForeignTitleFactory implements ForeignTitleFactory { public function createForeignTitle( $title, $ns = null ) { $pieces = explode( ':', $title, 2 ); - global $wgContLang; - - // Can we assume that the part of the page title before the colon is a - // namespace name? - // - // XML export schema version 0.5 and earlier (MW 1.18 and earlier) does not - // contain a tag, so we need to be able to handle that case. - // - // If we know the namespace ID, we assume a non-zero namespace ID means - // the ':' sets off a valid namespace name. If we don't know the namespace - // ID, we fall back to using the local wiki's namespace names to resolve - // this -- better than nothing, and mimics the old crappy behavior - $isNamespacePartValid = is_null( $ns ) ? - ( $wgContLang->getNsIndex( $pieces[0] ) !== false ) : - $ns != 0; + /** + * Can we assume that the part of the page title before the colon is a + * namespace name? + * + * XML export schema version 0.5 and earlier (MW 1.18 and earlier) does not + * contain a tag, so we need to be able to handle that case. + * + * If we know the namespace ID, we assume a non-zero namespace ID means + * the ':' sets off a valid namespace name. If we don't know the namespace + * ID, we fall back to using the local wiki's namespace names to resolve + * this -- better than nothing, and mimics the old crappy behavior + */ + $isNamespacePartValid = is_null( $ns ) + ? MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $pieces[0] ) !== + false + : $ns != 0; if ( count( $pieces ) === 2 && $isNamespacePartValid ) { list( $namespaceName, $pageName ) = $pieces;