r21387 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21386‎ | r21387 | r21388 >
Date:18:47, 19 April 2007
Author:vyznev
Status:old
Tags:
Comment:
reapply r21363, hopefully without stupid notices this time
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1645,12 +1645,7 @@
16461646 $m = array();
16471647 if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $dbkey, $m ) ) {
16481648 $p = $m[1];
1649 - $lowerNs = $wgContLang->lc( $p );
1650 - if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) {
1651 - # Canonical namespace
1652 - $dbkey = $m[2];
1653 - $this->mNamespace = $ns;
1654 - } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) {
 1649+ if ( $ns = $wgContLang->getNsIndex( $p )) {
16551650 # Ordinary namespace
16561651 $dbkey = $m[2];
16571652 $this->mNamespace = $ns;
Index: trunk/phase3/languages/Language.php
@@ -228,14 +228,30 @@
229229 }
230230
231231 /**
232 - * Get a namespace key by value, case insensetive.
 232+ * Get a namespace key by value, case insensitive.
 233+ * Only matches namespace names for the current language, not the
 234+ * canonical ones defined in Namespace.php.
233235 *
234236 * @param string $text
235237 * @return mixed An integer if $text is a valid value otherwise false
236238 */
 239+ function getLocalNsIndex( $text ) {
 240+ $this->load();
 241+ $lctext = $this->lc($text);
 242+ return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
 243+ }
 244+
 245+ /**
 246+ * Get a namespace key by value, case insensitive. Canonical namespace
 247+ * names override custom ones defined for the current language.
 248+ *
 249+ * @param string $text
 250+ * @return mixed An integer if $text is a valid value otherwise false
 251+ */
237252 function getNsIndex( $text ) {
238253 $this->load();
239254 $lctext = $this->lc($text);
 255+ if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
240256 return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
241257 }
242258

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r21363make ->getNsIndex() check canonical namespace names too, remove now redundant...vyznev10:03, 19 April 2007