jenkins-bot has submitted this change and it was merged. ( 
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(-)

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



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: merged
Gerrit-Change-Id: Ie8c217fdc8bd783b30f98210309ea56fef39c0da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to