MediaWiki extensions to define their MediaWiki compatibility

Over the past year support for real dependency management has been gradually added to MediaWiki and selected extensions. This support being based on the Composer software.

While extensions have been able to specify their dependencies for a while, such as PHP libraries and other extensions, they where not able to specify the MediaWiki versions they work with. The reason for this being that there is simply no MediaWiki package. Extensions are installed into MediaWiki, as opposed to people installing a MediaWiki package (and its dependencies) into something else. Changing this would resolve the issue, though I’m not sure this is a good idea. What I am however sure of is that such a change is not going to be made any time soon for mainly political reasons. I have now tackled the issue using an alternative approach that requires no change to existing workflows and can be happily ignored by people afraid from evil things such as third party software, namespaces and anonymous functions.

This alternative approach is based on adding a “provide” package link to the root package (this is the package into which extensions are installed). If this provide link points to a mediawiki package with specific version, then extensions can specify they need this version, and have this requirement satisfied on installation in the root package. Rather then having this link defined in composer.json, which would mean people would need to update the version there manually or an automatic composer.json-modifier would need to be created, the link is added programatically via a Composer hook.

Extensions will thus be able to specify their compatibility as follows (in their composer.json):

The commit adding this capability to MediaWiki is awaiting review on Gerrit. Many thanks go to @beausimensen for providing the basis of this idea and helping with implementation. Thanks also go to @seldaek for tweaking Composer so this approach would actually work.

5 thoughts on “MediaWiki extensions to define their MediaWiki compatibility”

  1. While this is a good idea and I appreciate it, I am not sure if I can make much use of it with extensions. As far as I know, there is currently no way to test extensions in different Mediawiki version settings. As a developer, you would have to remember every single line of code in your extension and be aware of every single change in Mediawiki versions, that might affect your extension, in order to know what the minimum or maximum version of Mediawiki is, that your extension can run on.

    So I don’t know what I should add as a version. If I am too conservative in my estimates, I unnecessarily prevent others from using my extension. If I am too broad in my assumptions, people might complain, that the extension doesn’t work despite me claiming that it should work with the used Mediawiki version.

    1. There are many approaches one can take to minimize binding with MediaWiki and thus reduce things that can break or depend on its version. Most of that falls into the general categories of not binding to frameworks and minimizing dependencies. I can highly recommend looking into these topics if you have not already done so, as they are must knows for most software developers.

      The premise that one cannot test which versions of MediaWiki your extension is compatible with is flawed.

      These are the versions SMW is compatible with: https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/INSTALL.md#versions

      And we can guarantee compatibility by running our tests against different versions of MediaWiki: https://travis-ci.org/SemanticMediaWiki/SemanticMediaWiki

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.