Topic on Talk:Requests for comment/Extension management with Composer

MediaWiki compatibility

7
Jeroen De Dauw (talkcontribs)

The approach currently used by SMW and some other extensions does not allow specifying which MW versions are supported as far as I know. Using a meta package into which both MW and extensions are installed would solve the issue, though hardly seems like a viable approach at this point. (This means a big workflow change and requires all global scope assumptions in core to be fixed first.) I'm investigating how to do this in a way that can be used in the near future. If anyone figured this out, I'd be very interested in the details.

Jeroen De Dauw (talkcontribs)

I had a long chat with simensen on #composer about this. We came to the conclusion that having "provide": { "mediawiki/mediawiki": "$wgVersion" } in the root composer.json. This then allows extensions to specify which MW versions they are compatible with. Still figuring out how to best implement this.

Actually putting this code into the file is somewhat problematic, as it needs to be updated whenever the MW version changes. Having users do this manually is clearly problematic. Thus we either need to automatically update this, or not actually have the info be in the file itself, but rather added problematically via a Composer hook.

I tried using the Composer scripts system, which unfortunately gets initialized too late to add things to the provide section. Then I tried using the plugin mechanism and having the handling code in MediaWiki itself. This also did not work, as the plugin system apparently requires using a dedicated package. My third try was updating the version on run of update.php, for which I have code here. This is also not going to work, as MediaWiki is already loaded when this script runs, and would thus require a re-run or some other silliness.

A regular plugin (in its own package) could presumably be used, though it'd first need to be installed. This thus requires running composer install before adding any extensions to composer.json. That sucks.

I'll further poke people about this. Perhaps a new hook in Composer is needed, or an enhancement to the plugin system.

Dantman (talkcontribs)

What about fixing composer so that it can install things via {composer} install $package_name without requiring they be present in the composer.json?

This would allow you to have a proper composer.json committed to git with all the provide, dependency, etc... information already written in it.

Jeroen De Dauw (talkcontribs)

By all means, create a feature request on the Composer project.

Jeroen De Dauw (talkcontribs)
Jeroen De Dauw (talkcontribs)

The issue has been resolved, so the "provide" approach is now viable. Implementation in this commit.

BDavis (WMF) (talkcontribs)

I have proposed a patch at Gerrit change 162367 to restore the Composer hook integration to MediaWiki's composer.json file.

Reply to "MediaWiki compatibility"