Page MenuHomePhabricator

Cannot create namespace alias to NS_MAIN
Closed, ResolvedPublic

Description

Author: quietust

Description:
Attempting to create a namespace alias which links to NS_MAIN results in the entry being completely ignored. Aliases to other namespaces work just fine.

I was able to solve this problem by editing the function Title::secureAndSplit() as follows:

			$m = array();
			if ( preg_match( $prefixRegexp, $dbkey, $m ) ) {
				$p = $m[1];
  • if ( $ns = $wgContLang->getNsIndex( $p ) ) {

+ if (( $ns = $wgContLang->getNsIndex( $p ) ) !== false) {

  1. Ordinary namespace
					$dbkey = $m[2];
					$this->mNamespace = $ns;

The function Language::getNsIndex() explicitly returns FALSE if the namespace name is not found, but since the above code does not check the type of the return value, a namespace ID of 0 (that is, NS_MAIN) is treated as nonexistent.

A quick glance at SVN (in mediawiki/trunk/phase3) suggests that this issue may still be present in the latest version.


Version: 1.15.x
Severity: normal
OS: Windows XP

Details

Reference
bz22940

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:01 PM
bzimport set Reference to bz22940.
bzimport added a subscriber: Unknown Object (MLST).
  • Bug 23842 has been marked as a duplicate of this bug. ***