jenkins-bot has submitted this change and it was merged.

Change subject: registration: Fix namespaces added through the 
ExtensionProcessor
......................................................................


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
---
M includes/DefaultSettings.php
M includes/MWNamespace.php
M includes/registration/ExtensionProcessor.php
3 files changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 75ed529..ff32ccf 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -3636,8 +3636,8 @@
  * 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 bd68551..e370bf1 100644
--- a/includes/MWNamespace.php
+++ b/includes/MWNamespace.php
@@ -210,6 +210,8 @@
                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 3564c71..093ffbc 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -210,7 +210,7 @@
                        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'];
                                }

-- 
To view, visit https://gerrit.wikimedia.org/r/237973
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5bd9a7258f59d8c4a7ad0543d2115960fbea9b3a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_25
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Gilles <gdu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to