registration: Support conditionally registered namespaces
authorKunal Mehta <legoktm@member.fsf.org>
Fri, 29 Jul 2016 08:09:24 +0000 (01:09 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Fri, 29 Jul 2016 08:09:24 +0000 (01:09 -0700)
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

docs/extension.schema.json
docs/extension.schema.v1.json
includes/registration/ExtensionProcessor.php

index f2406c8..110e99d 100644 (file)
                                        "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"]
index 893facf..37235e9 100644 (file)
                                        "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"]
index 9563fc0..5555e8b 100644 (file)
@@ -243,7 +243,10 @@ class ExtensionProcessor implements Processor {
                        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'];
                                }