Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Simplified initialization #105

Merged
merged 1 commit into from Sep 3, 2016
Merged

Simplified initialization #105

merged 1 commit into from Sep 3, 2016

Conversation

JeroenDeDauw
Copy link
Member

No longer spread out over so many files

Now using anon functions, and breaking out of static/global scope

No longer spread out over so many files

Now using anon functions, and breaking out of static/global scope
@JeroenDeDauw
Copy link
Member Author

This needs testing... I don't have a wiki so that's kinda difficult


$GLOBALS['wgExtensionFunctions'][] = function() {
SemanticMaps::onExtensionFunction();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I introduced public static function onExtensionFunction for a reason instead of relying on $GLOBALS['wgExtensionFunctions'][] in order to switch to extension.json at some point using something like:

    ...
    "AutoloadClasses": {
        "SemanticMaps": "SemanticMaps.php"
    },
    "callback": "SemanticMaps::initExtension",
    "ExtensionFunctions": [
        "SemanticMaps::onExtensionFunction"
    ],
    "load_composer_autoloader":true,
    "manifest_version": 1

callback and ExtensionFunctions have a different execution timing when used with extension.json.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. Is the idea that SemanticMaps.php would not be included at all then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to recall what I did with/in SemanticMediaWiki/SemanticMediaWiki#1732.

In case one switches to use extension.json, wfLoadExtension( 'SemanticMaps' ); is suppose to invoke SemanticMaps.php using:

    "AutoloadClasses": {
        "SemanticMaps": "SemanticMaps.php"
    },

SemanticMaps would only be loaded at the time wfLoadExtension is called. As of now, SemanticMaps.php is autoloaded using Composer.

    "autoload": {
        "files" : [
            "DefaultSettings.php",
            "SemanticMaps.php"
        ],

The idea is that DefaultSettings.phpis always loaded first (and present before LocalSettings.php) and independent of the handler system (PHP vs. json) but SemanticMaps.php should be removed by the time you switch the system to ensure wfLoadExtension becomes the handler for the SemanticMaps instance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I don't fully understand but suspect I get the gist of it.

As far as I can tell it's trivial to add a new static function once such extension.json support is added, so are you fine with the code looking like this for now?

@JeroenDeDauw JeroenDeDauw merged commit 116ae5a into master Sep 3, 2016
@JeroenDeDauw JeroenDeDauw deleted the simplify-initialization branch September 3, 2016 03:12
@JeroenDeDauw
Copy link
Member Author

Merging so I can see in a day if the maps on the test wiki are still working :) Such feedback cycle

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants