Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/361199 )

Change subject: registration: Support conditionally registered namespaces
......................................................................

registration: Support conditionally registered namespaces

Some extensions (e.g. EventLogging) conditionally register a namespace
depending upon the wiki's configuration using the CanonicalNamespaces
hook. Since the "namespaces" key automatically registers the namespace,
we need an option to not register it and let the extension take care of
that manually using the hook.

All of the other namespace related settings are safe to unconditionally
set since they won't do anything if the namespace doesn't actually
exist.

Bug: T141604
Change-Id: Ie8c217fdc8bd783b30f98210309ea56fef39c0da
---
M docs/extension.schema.json
M includes/registration/ExtensionProcessor.php
2 files changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/99/361199/1

diff --git a/docs/extension.schema.json b/docs/extension.schema.json
index 1d2b2f0..5995975 100644
--- a/docs/extension.schema.json
+++ b/docs/extension.schema.json
@@ -579,6 +579,11 @@
                                        "capitallinkoverride": {
                                                "type": "boolean",
                                                "description": "Set 
$wgCapitalLinks on a per-namespace basis"
+                                       },
+                                       "conditional": {
+                                               "type": "boolean",
+                                               "description": "Whether the 
namespace is conditional upon configuration and should not be registered 
(requires separate registration via a hook)",
+                                               "default": false
                                        }
                                },
                                "required": ["id", "constant", "name"]
diff --git a/includes/registration/ExtensionProcessor.php 
b/includes/registration/ExtensionProcessor.php
index 78f9370..3763960 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -233,7 +233,10 @@
                        foreach ( $info['namespaces'] as $ns ) {
                                $id = $ns['id'];
                                $this->defines[$ns['constant']] = $id;
-                               $this->attributes['ExtensionNamespaces'][$id] = 
$ns['name'];
+                               if ( !( isset( $ns['conditional'] ) && 
$ns['conditional'] ) ) {
+                                       // If it is not conditional, register it
+                                       
$this->attributes['ExtensionNamespaces'][$id] = $ns['name'];
+                               }
                                if ( isset( $ns['gender'] ) ) {
                                        
$this->globals['wgExtraGenderNamespaces'][$id] = $ns['gender'];
                                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8c217fdc8bd783b30f98210309ea56fef39c0da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to