registration: Fix namespaces added through the ExtensionProcessor
authorKunal Mehta <legoktm@gmail.com>
Wed, 26 Aug 2015 21:18:39 +0000 (14:18 -0700)
committerTim Starling <tstarling@wikimedia.org>
Thu, 27 Aug 2015 03:03:43 +0000 (03:03 +0000)
Using $wgExtraNamespaces overrides any localized namespaces with the
canonical form, which is not ideal.

Namespaces added through extension.json will now store the canonical
form and numerical id in a 'ExtensionNamespaces' attribute that is read
by MWNamespace::getCanonicalNamespaces().

Also fix the documentation on $wgExtraNamespaces, as using
$wgCanonicalNamespaceNames has not been possible since r85327.

Bug: T110389
Change-Id: I5bd9a7258f59d8c4a7ad0543d2115960fbea9b3a

includes/DefaultSettings.php
includes/MWNamespace.php
includes/registration/ExtensionProcessor.php

index de356ad..bcf7e14 100644 (file)
@@ -3720,8 +3720,8 @@ $wgMetaNamespaceTalk = false;
  * Additional namespaces. If the namespaces defined in Language.php and
  * Namespace.php are insufficient, you can create new ones here, for example,
  * to import Help files in other languages. You can also override the namespace
- * names of existing namespaces. Extensions developers should use
- * $wgCanonicalNamespaceNames.
+ * names of existing namespaces. Extensions should use the CanonicalNamespaces
+ * hook or extension.json.
  *
  * @warning Once you delete a namespace, the pages in that namespace will
  * no longer be accessible. If you rename it, then you can access them through
index 731b62e..8ca205a 100644 (file)
@@ -210,6 +210,8 @@ class MWNamespace {
                if ( $namespaces === null || $rebuild ) {
                        global $wgExtraNamespaces, $wgCanonicalNamespaceNames;
                        $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames;
+                       // Add extension namespaces
+                       $namespaces += ExtensionRegistry::getInstance()->getAttribute( 'ExtensionNamespaces' );
                        if ( is_array( $wgExtraNamespaces ) ) {
                                $namespaces += $wgExtraNamespaces;
                        }
index 68e5a17..2c792da 100644 (file)
@@ -213,7 +213,7 @@ class ExtensionProcessor implements Processor {
                        foreach ( $info['namespaces'] as $ns ) {
                                $id = $ns['id'];
                                $this->defines[$ns['constant']] = $id;
-                               $this->globals['wgExtraNamespaces'][$id] = $ns['name'];
+                               $this->attributes['ExtensionNamespaces'][$id] = $ns['name'];
                                if ( isset( $ns['gender'] ) ) {
                                        $this->globals['wgExtraGenderNamespaces'][$id] = $ns['gender'];
                                }