From: Ilmari Karonen Date: Thu, 19 Apr 2007 10:03:32 +0000 (+0000) Subject: make ->getNsIndex() check canonical namespace names too, remove now redundant explici... X-Git-Tag: 1.31.0-rc.0~53365 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=8bd0a936094fae949a2a8e5e6936faaef98c5a9b;p=lhc%2Fweb%2Fwiklou.git make ->getNsIndex() check canonical namespace names too, remove now redundant explicit check from Title.php; as far as I can tell this shouldn't break anything, and arguably it'll fix some currently broken code. introduce new function getLocalNsIndex() to provide the old functionality, should anyone actually need it. --- diff --git a/includes/Title.php b/includes/Title.php index d7b29ec34b..531944aae5 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1645,12 +1645,7 @@ class Title { $m = array(); if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $dbkey, $m ) ) { $p = $m[1]; - $lowerNs = $wgContLang->lc( $p ); - if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) { - # Canonical namespace - $dbkey = $m[2]; - $this->mNamespace = $ns; - } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) { + if ( $ns = $wgContLang->getNsIndex( $p )) { # Ordinary namespace $dbkey = $m[2]; $this->mNamespace = $ns; diff --git a/languages/Language.php b/languages/Language.php index 4f217918c6..cc12fe9496 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -228,7 +228,23 @@ class Language { } /** - * Get a namespace key by value, case insensetive. + * Get a namespace key by value, case insensitive. + * Only matches namespace names for the current language, not the + * canonical ones defined in Namespace.php. + * + * @param string $text + * @return mixed An integer if $text is a valid value otherwise false + */ + function getLocalNsIndex( $text ) { + $this->load(); + $lctext = $this->lc($text); + if( ( $ns = $this->mNamespaceIds[$lctext] ) !== null ) return $ns; + return false; + } + + /** + * Get a namespace key by value, case insensitive. Canonical namespace + * names override custom ones defined for the current language. * * @param string $text * @return mixed An integer if $text is a valid value otherwise false @@ -236,7 +252,9 @@ class Language { function getNsIndex( $text ) { $this->load(); $lctext = $this->lc($text); - return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false; + if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns; + if( ( $ns = $this->mNamespaceIds[$lctext] ) !== null ) return $ns; + return false; } /**