Problem/Motivation
The upgrade status module seems to be incompatible with nikic/php-parser v5.0.0
Steps to reproduce
When I run: composer require 'drupal/upgrade_status:^4.0.0' I get the following error:
Problem 1
- Root composer.json requires drupal/upgrade_status ^4.0.0 -> satisfiable by drupal/upgrade_status[4.0.0-alpha1, 4.0.0, 4.x-dev].
- drupal/upgrade_status[4.0.0-alpha1, ..., 4.x-dev] require nikic/php-parser ^4.0.0 -> found nikic/php-parser[v4.0.0alpha1, ..., 4.x-dev] but the package is fixed to v5.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Is this module compatible with nikic/php-parser v5.0.0?
Issue fork upgrade_status-3421454
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gábor hojtsyOnly the https://git.drupalcode.org/project/upgrade_status/-/blob/4.x/src/ThemeFu... uses the PHP parser I think directly. It would need to be attempted whether there were any API changes related to those uses.
Comment #4
gábor hojtsyInterestingly it only fails on Drupal 9 with
Comment #5
gábor hojtsyThis is where this fails, so clearly does not do the theme function checking properly:
Help is welcome to figure out how to make it compatible :)
Comment #7
gábor hojtsyKeeping v4 did not help, Drupal 9 would also take v5 and still fail there. It does not fail in Drupal 10 because the code it would affect does not actually run, so it does not help. Would be nice if composer would have optional dependencies based on dependency criteria haha. Since we don't seem to need it in the Drupal 10 to 11 path. Anyway, until then the solution is to make it work :) Help still welcome.
Comment #8
gábor hojtsyComment #9
ressaThanks for the patch @Gábor Hojtsy!
I am not sure how to check if this fixes the Composer block ... After cloning and applying the patch, I tried running
composer installinside the module, but nothing happened ... so I ended up installing the required external projects manually:Most importantly, the
nikic/php-parserparser was installed using those constraints:After these steps, I get the expected warnings on the report page:
I think this is a critical bug for the Upgrade Status module, since it's currently not possible to install in Drupal 9 with Composer, you need to
git cloneand install libraries with Composer as seen above (or maybe there is another method?) so changing the Status.Comment #10
ressaComment #11
ressaI created #3426870: Add test: Can Upgrade Status be downloaded with Composer?.
Comment #12
gábor hojtsy@ressa: but Drupal 9 does not require nikic/php-parser v5.0.0? This definitely cannot be committed as-is as shown by the test fails, it does not find theme functions anymore. There are likely changes in the parser in v5 that need to be accounted for in our uses of its classes/interfaces.
Comment #13
ressaSorry @Gábor Hojtsy, I was wrong.
I think what happened was that I tried to download the Upgrade Status module with Composer having Drush installed, and got this error:
Since
nikic/php-parserwas the only non-Drupal project mentioned, I searched for that, and found this issue. Also, I am pretty sure I tried removing Drush, tried again, and failed ...But I now read the tip on the project page about removing Drush. So I tried again just now with a fresh install with Drush installed, and failed (as expected) to confirm the problem. After removing Drush, the module installed without a problem, and works well. Sorry about the noise!
To make it more likely people find the hint on the project page when they search for help, perhaps
nikic/php-parsercould be mentioned, if that's always the problem?Alternatively, and maybe better: Since you get this error in a standard fresh Drupal 9 installation with Drush installed, I suppose the majority run into this problem, right? Wouldn't it then be better, if the project page simply said this?
Comment #14
gábor hojtsyOk I started looking into this a bit more. First the code has this comment
So it could be mostly safely removed in a version that works only with Drupal 10 and 11. However since theme functions were deprecated in Drupal 8 and only removed in Drupal 10, the code compatible with Drupal 9 should still work. And that may still be installed with v5 of the parser, hm.
The theme function deprecation analyzer would not work on Drupal 10 anyway, due to the signature of the theme registry being different than how it uses it. But we don't run it on Drupal 10. :)
Comment #15
gábor hojtsyOk both the compatibility layer with and without v4 is green. That seems to be due to PHP 7.4+ being tested which all take v5 anyway. PHP 7.4 is the only version supported by Drupal 9 anyway, so I think that's a safe assumption for now. Hosts have been removing older PHP versions more aggressively recently. Given that though the version without the compatibility layer is better IMHO.
Comment #16
gábor hojtsyOk I also tried allowing PHP 7.3 to trigger the v4 of the parser from composer, but we also require Drush 11 which requires PHP 7.4+ so it is already not possible to install Upgrade Status on PHP 7.3 if you also use Drush. It would be quite some more work to go back and support Drush 10 again so we can keep Nikic v4 support. That sounds like a very theoretical scenario. So I think its fine to merge the v5 only update and accept that would be the version people go with. If there are reports of needing to go back and keep supporting v4 somehow, we can look into that then, but based on all I found here I don't expect that to happen.
Comment #18
gábor hojtsyComment #19
gábor hojtsyComment #20
gábor hojtsyNope not that simple. On another fresh setup this blocks installing Upgrade Status now because PHPUnit 9 depends on Nikic parser v4 :(
https://packagist.org/packages/phpunit/phpunit#9.6.x-dev requires https://packagist.org/packages/phpunit/php-code-coverage#9.2.28 which has a nikic/php-parser: ^4.15 dependency.
I have no idea how does the standalone version pass the phpunit tests, although I also run it and seen it with my own eyes. But looks like we'll need to keep v4 compatibility for phpunit's sake.
Made some adjustments on the compatibility MR to be on top of what we have now.
Comment #21
gábor hojtsyComment #23
gábor hojtsyComment #24
ressaThanks @Gábor Hojtsy, it's now possible to download the module, even WITH Drush already installed:
composer require drupal/upgrade_status:4.x-dev@devBut if I install the dev-tools with Drush present, I get this (it completes if I remove Drush):
That's probably harder to resolve ...
Since you get this error in a standard fresh Drupal 9 installation with Drush installed, and the majority probably run into this problem, is this rewording worth considering?
This can then be removed:
Comment #25
gábor hojtsyUpdated to this
Comment #26
ressaThanks, it's much clearer now what needs to be done, and updaters will encounter less bumps in the road :)
Regularly, someone should check if dev-tools and Drush might eventually co-exist in peace, and then step 1 and 5 can be removed.
Comment #27
ressaI am sorry I keep nagging about updating the steps. My only aim is make the upgrade process and future maintenance easier for non-experts.
Should we add this sentence, after the final step? After all, the majority of users will never need Drupal's developer dependencies ...