Don't allow user to create a Project namespace that conflicts with existing namespaces
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 28 Feb 2011 23:15:14 +0000 (23:15 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 28 Feb 2011 23:15:14 +0000 (23:15 +0000)
includes/installer/Installer.i18n.php
includes/installer/WebInstallerPage.php

index e60728f..a3247de 100644 (file)
@@ -328,6 +328,8 @@ In '''UTF-8 mode''', MySQL will know what character set your data is in, and can
 All page titles in this namespace start with a certain prefix, which you can specify here.
 Traditionally, this prefix is derived from the name of the wiki, but it cannot contain punctuation characters such as "#" or ":".',
        'config-ns-invalid'               => 'The specified namespace "<nowiki>$1</nowiki>" is invalid.
+Specify a different project namespace.',
+       'config-ns-conflict'               => 'The specified namespace "<nowiki>$1</nowiki>" conflicts with a default MediaWiki namespace.
 Specify a different project namespace.',
        'config-admin-box'                => 'Administrator account',
        'config-admin-name'               => 'Your name:',
index afbd7c0..090f03c 100644 (file)
@@ -666,6 +666,15 @@ class WebInstaller_Name extends WebInstallerPage {
                        $this->parent->showError( 'config-ns-invalid', $name );
                        $retVal = false;
                }
+
+               // Make sure it won't conflict with any existing namespaces
+               global $wgContLang;
+               $nsIndex = $wgContLang->getNsIndex( $name );
+               if( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
+                       $this->parent->showError( 'config-ns-conflict', $name );
+                       $retVal = false;
+               }
+
                $this->setVar( 'wgMetaNamespace', $name );
 
                // Validate username for creation