-
Notifications
You must be signed in to change notification settings - Fork 86
Support requires and requires_php in plugin/theme list and update command #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…mands This introduces a new update sate of 'unavailable' which is when there is a new version of a theme/plugin upstream but the local WordPress / PHP requirements do not meet the requirements set by the authors.
Thanks a lot for working on this! I haven't tested it yet, but it looks very promising already. It will be very useful for better managing updates when knowing that newer (albeit incompatible) versions are available. On that note, what do you think about renaming IMO |
Interesting, I picked
|
@wp-cli/committers @wp-cli/maintainers any preference here on the wording? Also generally a review here is appreciated :) |
The plugins update-check api doesn't actually work with older versions of WordPress, for two reasons: The first is that the no_updates field wasn't added til 4.0 The second is that the request that WP itself makes to the plugins update API is missing &all=true which causes the API to always return an empty response in my testing. Both of these were added in 4.0 here: WordPress/wordpress-develop@b00097b
Astra requires at least WordPress 5.3 so this test no longer applies since we flag the update as unavailable. Switch to twentythirteen which has lower WP requriements and is better to use for testing old versions
Older versions of WordPress already have this installed (!) We want to force this older version since we know there will be updates.
This is going to have different results across different versions of WordPress now, because output depends on the upstream requirements of what we are testing. Update test so that the update status is variable and we specify the fields otherwise it would sometimes show additional fields explaining the reason an update is unavailable
@swissspidy I updated tests for this to use new HTTP mock feature which works well here (and makes testing more reliable). The only remaining PHP 5.6 / PHP 3.7 issues are because we use Moina in many tests and it does not support WP 3.7 so it now correctly throws an error. If there is an interest in merging this, I'm happy to go through and fix the tests before merge (probably just replacing with twentyten). |
I'm definitely interested in merging this! Replacing the theme with another one or just adding some As for the unavailable vs incompatible question, I don't feel strongly. Let's stick with unavailable for now. |
WordPress Trunk actually includes all of these past default themes so the output is different. Put behind a version guard instead
I added them behind require flags because trunk actually includes every previous default theme (unlike releases) and gives different output when a theme is already installed. All tests passing now 🚥 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, thanks for this!
This introduces a new update sate of 'unavailable' which is when there is a new version of a theme/plugin upstream but the local WordPress / PHP requirements do not meet the requirements set by the authors.
What this changes:
Changes the
update
field of an item from a bool which laters gets turned into 'available' or 'none' to a string which will be either'available'
,'none'
, or'unavailable'
. Newunavailable
is based off a check against WordPress and PHP requirements via therequires
andrequires_php
fields.This works similarly for PHP versions too:
This also fixes issues like #428 by removing incompatible updates from a command like:
This also adds the fields
requires
andrequires_php
. While these aren't default fields, I did change it so that it will include them by default if one of the plugins has an update sate of unavailable (so it is immediately clear why the update is unavailable).I've also written it so that
requires
andrequires_php
fields will use either what is provided for the latest version in the case of an update (unavailable or not) or whatever is listed in the current plugin file.This means that in the case of 'none' it i showing the requirements for the current version, while in the case of 'available' or 'unavailable' it is showing the requirements for the
update_version
. This could be a bit confusing, but it made even less sense the other way to have it list an update as 'unavailable' while showing the older and already met requirements from the currently installed version. Those were just my initial idea, so any feedback welcome there. Similar to the field names, etc...Finally, I couldn't find much documentation about the wordpress.org update API, but what I saw in testing is:
For plugins, the wordpress.org api will check the version of WordPress sent in the header of the request from wp core and if the latest upstream version requires a newer version of WordPress, it moves that plugin into the
no_update
section of the response, along with any other plugins that just don't have an update available. It doesn't know the current version of PHP, so it can't check that. The current situation is that if an upstream update requires a newer version of WordPress then WP CLI doesn't see it at all, because it doesn't look for it in theno_updates
section of the response. If it requires a newer version of PHP, WP CLI will show it as an available update because it doesn't know about the PHP incompatibility.For themes, it doesn't seem to do that same filtering.
This PR fixes both those cases by correctly showing the updates as
unavailable
rather than not existing or ready to install. My main use case is that I want to be able to runwp plugin list
and see if a site is running the latest version of any installed plugin or theme. If not, I want to know if it is because the updates haven't been applied or if they are held back because of requirement changes in newer versions.