From: Kunal Mehta Date: Fri, 29 Jul 2016 08:09:24 +0000 (-0700) Subject: registration: Support conditionally registered namespaces X-Git-Tag: 1.31.0-rc.0~6222^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=93aed1e7eb0761d8673f57bde733272a83ade1f9;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/docs/extension.schema.json b/docs/extension.schema.json index f2406c8ee7..110e99d4e6 100644 --- a/docs/extension.schema.json +++ b/docs/extension.schema.json @@ -625,6 +625,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/docs/extension.schema.v1.json b/docs/extension.schema.v1.json index 893facfd7a..37235e93ab 100644 --- a/docs/extension.schema.v1.json +++ b/docs/extension.schema.v1.json @@ -615,6 +615,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 9563fc09f2..5555e8b2bc 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -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']; }