Page MenuHomePhabricator

Decide whether extensions should set a PHP version requirement in composer.json
Closed, ResolvedPublic

Description

This has emerged while upgrading PHPCS to the latest version for all repos (and hence, starting to use PHP72+ features). Currently, many extensions have an explicit PHP version requirement in composer.json.

Aside from special cases (i.e. extensions which already required PHP7+), several extensions require PHP 5.6.99+, which was the "correct" value as long as we supported HHVM.

Others have different requirements, varying from 5.0.0 (!) to 5.5.9. For some of them, it's safe to assume that the intention was to require the same version as MW core, but they fell out of date.

However, others are actually (claimed to be) compatible with PHP5. For instance, some extensions with "master" compatibility.

The goal of this task is to understand whether, and under what premises, an extension may set an explicit PHP requirement in its composer.json. And ideally, what PHP versions are admissible, too.

Personally, I think it doesn't make any sense to try to support a PHP version < than the version supported by the oldest supported release of MW.

For instance, since right now MW 1.31 is the oldest supported version and it only supports HHVM or PHP7+, *every* extension should do the same (i.e. the composer requirement should be 5.6.99+). IMHO this is a no-brainer.


I (@Daimona) think that extensions should *not* have an explicit PHP version requirement, unless it's (meant to be) different from the one in core.

Event Timeline

I (@Daimona) think that extensions should *not* have an explicit PHP version requirement, unless it's (meant to be) different from the one in core.

That's kinda the view I'd taken, at least when adding or suggesting others to add them. For example the WebAuthn, which needed PHP 7.2 due the the 3rd party libraries it used, but it was mostly developed when MW master still needed HHVM support and therefore it could've used HHVM

It's worth noting an extension can set it in extension.json too, which can have differing results. Which can potentially give some other clues... If the file has a requires MW >= some old version, the PHP version might make more sense. Especially as we're trying to be more rigorous about setting the requires MW in extension.json, so we don't necessarily have to enforce the "use the same branch of MW for the extension" -- if master says it should work... It should work (or else that's a separate bug)

I implemented the php requirements for extension.json, and @Legoktm and me thought it should be used the same way @Daimona proposes: A php requirement should only be specified, if an extension requires a php version higher than the minimum supported php version for the minimum supported MW core version. I think for composer.json, we should use the same approach.

I implemented the php requirements for extension.json, and @Legoktm and me thought it should be used the same way @Daimona proposes: A php requirement should only be specified, if an extension requires a php version higher than the minimum supported php version for the minimum supported MW core version. I think for composer.json, we should use the same approach.

Got the task/reference to hand? Always worth linking back where possible

Krinkle claimed this task.

Circling back to this. It seems by now (codesearcj) very few (~10) deployed extensions still set php in their composer.json.

Given Daimona and Reedy were both in favour of removing it, and this is also least to maintain and for PHPCS to automatically work correctly via lib-up, I think we can call this resolved. If we do find a use case for setting it in each repo separately, then I'd suggest we task LibUp with keeping this in sync with some way to opt-out (e.g. based on the signal in extension.json as per T197535; which we'd continue to only set when it must be different from core; and then always set in composer.json with LibUp keeping it in sync with that override or the current value in core).