From: jenkins-bot Date: Mon, 16 Apr 2018 16:55:43 +0000 (+0000) Subject: Merge "Title: Simplify use of MWNamespace::getCanonicalName()" X-Git-Tag: 1.31.0-rc.0~61 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=5c357bf6c28eb0c3462374e088a6583eecbd2953;hp=4cd4976fb1d559401f0ade950e24e5438f1cb8b6 Merge "Title: Simplify use of MWNamespace::getCanonicalName()" --- diff --git a/includes/Title.php b/includes/Title.php index 58e688589f..b771477fad 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1027,12 +1027,11 @@ class Title implements LinkTarget { */ public function getNsText() { if ( $this->isExternal() ) { - // This probably shouldn't even happen, - // but for interwiki transclusion it sometimes does. - // Use the canonical namespaces if possible to try to - // resolve a foreign namespace. - if ( MWNamespace::exists( $this->mNamespace ) ) { - return MWNamespace::getCanonicalName( $this->mNamespace ); + // This probably shouldn't even happen, except for interwiki transclusion. + // If possible, use the canonical name for the foreign namespace. + $nsText = MWNamespace::getCanonicalName( $this->mNamespace ); + if ( $nsText !== false ) { + return $nsText; } } @@ -4795,14 +4794,12 @@ class Title implements LinkTarget { */ public function getNamespaceKey( $prepend = 'nstab-' ) { global $wgContLang; - // Gets the subject namespace if this title - $namespace = MWNamespace::getSubject( $this->getNamespace() ); - // Checks if canonical namespace name exists for namespace - if ( MWNamespace::exists( $this->getNamespace() ) ) { - // Uses canonical namespace name - $namespaceKey = MWNamespace::getCanonicalName( $namespace ); - } else { - // Uses text of namespace + // Gets the subject namespace of this title + $subjectNS = MWNamespace::getSubject( $this->getNamespace() ); + // Prefer canonical namespace name for HTML IDs + $namespaceKey = MWNamespace::getCanonicalName( $subjectNS ); + if ( $namespaceKey === false ) { + // Fallback to localised text $namespaceKey = $this->getSubjectNsText(); } // Makes namespace key lowercase