Continuing the experimental journey for a possible extension.json [0] conversion, I'm faced with a different issue relating to namespace declarations that can be "dynamic" or better depend on a custom setting.
It has been from the beginning of the extension and so it is expected that in future namespaces like (SMW_NS_PROPERTY, SMW_NS_CONCEPT etc.) remain dynamic and can shift from installation to installation because customers may have different policies on how to allocate those numbers [1] (default is 102+ [2]).
Currently, we require a enableSemantics setting in LocalSettings to fetch the necessary ID offset and make it immediately DEFINE the number range to ensure that the CanonicalNamespaces hook has access to that information as soon as possible when called during the hook execution.
It also ensures that any setting in LocalSettings called after enableSemantics has access to SMW_NS_PROPERTY without running into a "Use of undefined constant SMW_NS_PROPERTY - assumed 'SMW_NS_PROPERTY" [0] issue.
Now, in case of extension.json having users to maintain both, seems counterintuitive to what we want to achieve with wfLoadExtension (enabling the extension).
wfLoadExtension( 'SemanticMediaWiki' ); enableSemantics( 'example.org' );
The problem is that wfLoadExtension is executed after LocalSettings has been finished loading which is obviously to late and would generate a Use of undefined constant SMW_NS_PROPERTY ... error when referenced in the LocalSettings without the enableSemantics call being present.
There are two possible solutions:
- enableSemantics itself calls wfLoadExtension( 'SemanticMediaWiki' ) (and becomes hidden from LocalSettings itself) from within the function leaving the user to maintain only one "enabler" but comes at a cost of a hidden dependency which goes against SRP and my personal design principles
- wfLoadExtension provides an early something to cover that sort of scenario
Some thoughts on how to proceed would be appreciated and it should draw attention to existing use cases and hopefully avoid a possible disruption in future.
[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/1732
[1] https://github.com/wikimedia/mediawiki-extensions-BlueSpiceSMWConnector/blob/master/includes/DefaultSettings.SemanticMediaWiki.php#L3
[2] https://www.mediawiki.org/wiki/Extension_default_namespaces#Semantic_MediaWiki