From: Kunal Mehta Date: Wed, 26 Aug 2015 21:18:39 +0000 (-0700) Subject: registration: Fix namespaces added through the ExtensionProcessor X-Git-Tag: 1.31.0-rc.0~10252 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=9df0672255afd255ce0af34f18b8ad596f3c3e35;p=lhc%2Fweb%2Fwiklou.git registration: Fix namespaces added through the ExtensionProcessor 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 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index de356adf4b..bcf7e14c1f 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index 731b62e036..8ca205ab42 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -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; } diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 68e5a17796..2c792da125 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -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']; }