-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add requires_php
to the wp plugin list --update=available
output
#428
Comments
I'd like to work on this, but I'm not sure the premise of this issue is true. Does it actually show available updates where the minimum requirements aren't meant? In my experience, the opposite is true and what I want to address: WordPress / WP CLI shows there are no updates available, but the reality is the plugin has been updated yet the update can't be installed on the site. I'm not sure the best way to reflect that in the wp cli output. I'm not sure the best way to add I would like to figure out the best way to display to a user that there is a newer version of the plugin available upstream, but it can't be installed because either the version of PHP or WordPress is too low. Somewhat related to #436 but I want So it needs a way to show that there is a newer version available upstream, even if there is no update available for this particular site. I suppose it should also then explain why that newer version is not available. What might that look like? |
Yes, it does. Prior to WordPress/wordpress-develop@b00097b incompatible updates (WP version) were not shown, but since then the API has returned incompatible-with-your-WP. I believe the site will show a notice to that effect. The
This is not an issue; The needed fields are exposed in the API, and probably stored in the core transient. Example:
|
(sorry for longer response but thanks for encouraging me to look into it deeper) I'm not able to reproduce wp cli showing me updates for a plugin where the php / wp requirements are not met when I run Looking into what the code actually does, here is what I can say about how it works and why wp cli currently does not show an update available when it doesn't meet wp / php requirements: As you say, wp cli doesn't call the API directly, it uses the function wp_update_plugins from WordPress core. The response from the API server seems to already check requirements, and if they are not met it puts the upstream plugin details inside of the
wp cli then reads the extension-command/src/WP_CLI/CommandWithUpgrade.php Lines 535 to 538 in f0cebef
extension-command/src/WP_CLI/CommandWithUpgrade.php Lines 620 to 622 in f0cebef
However, wp cli only really checks inside the extension-command/src/Plugin_Command.php Line 760 in f0cebef
So you end up with an object like this: stdClass Object
(
[last_checked] => 1734626062
[response] => Array
(
[akismet/akismet.php] => stdClass Object
(
[id] => w.org/plugins/akismet
[slug] => akismet
[plugin] => akismet/akismet.php
[new_version] => 5.3.5
[url] => https://wordpress.org/plugins/akismet/
[package] => https://downloads.wordpress.org/plugin/akismet.5.3.5.zip
[icons] => Array
(
[2x] => https://ps.w.org/akismet/assets/icon-256x256.png?rev=2818463
[1x] => https://ps.w.org/akismet/assets/icon-128x128.png?rev=2818463
)
[banners] => Array
(
[2x] => https://ps.w.org/akismet/assets/banner-1544x500.png?rev=2900731
[1x] => https://ps.w.org/akismet/assets/banner-772x250.png?rev=2900731
)
[banners_rtl] => Array
(
)
[requires] => 5.8
[tested] => 6.7.1
[requires_php] => 5.6.20
[requires_plugins] => Array
(
)
)
)
[translations] => Array
(
)
[no_update] => Array
(
[hello.php] => stdClass Object
(
[id] => w.org/plugins/hello-dolly
[slug] => hello-dolly
[plugin] => hello.php
[new_version] => 1.7.2
[url] => https://wordpress.org/plugins/hello-dolly/
[package] => https://downloads.wordpress.org/plugin/hello-dolly.1.7.3.zip
[icons] => Array
(
[2x] => https://ps.w.org/hello-dolly/assets/icon-256x256.jpg?rev=2052855
[1x] => https://ps.w.org/hello-dolly/assets/icon-128x128.jpg?rev=2052855
)
[banners] => Array
(
[2x] => https://ps.w.org/hello-dolly/assets/banner-1544x500.jpg?rev=2645582
[1x] => https://ps.w.org/hello-dolly/assets/banner-772x250.jpg?rev=2052855
)
[banners_rtl] => Array
(
)
[requires] => 4.6
)
[wp-super-cache/wp-cache.php] => stdClass Object
(
[id] => w.org/plugins/wp-super-cache
[slug] => wp-super-cache
[plugin] => wp-super-cache/wp-cache.php
[new_version] => 1.12.4
[url] => https://wordpress.org/plugins/wp-super-cache/
[package] => https://downloads.wordpress.org/plugin/wp-super-cache.1.12.4.zip
[icons] => Array
(
[2x] => https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=1095422
[1x] => https://ps.w.org/wp-super-cache/assets/icon-128x128.png?rev=1095422
)
[banners] => Array
(
[2x] => https://ps.w.org/wp-super-cache/assets/banner-1544x500.png?rev=1082414
[1x] => https://ps.w.org/wp-super-cache/assets/banner-772x250.png?rev=1082414
)
[banners_rtl] => Array
(
)
[requires] => 6.5
[tested] => 6.6.2
[requires_php] => 7.0
[requires_plugins] => Array
(
)
)
)
[checked] => Array
(
[akismet/akismet.php] => 5.3
[hello.php] => 1.7.2
[wp-super-cache/wp-cache.php] => 1.9.4
)
) And wp cli output like this:
So wp cli says This is where my confusion with the initial issue description in, because it suggests that wp cli is showing these updates as available even though they don't meet requirements. In my example above, it is not showing them specifically because they didn't meet wp / php requirements when the API was called initially via WordPress core. So I consider the problem to be that it doesn't mention a newer version at all, when it should have a message saying that an update is available but you can't install it. Again, I'd be interested in an example to reproduce the original issue claim that the opposite happens. I could imagine there is some case where the API does not do the check server side and does return an update available -- but I haven't seen that. So for the problem of wp cli not showing newer releases: Earlier I said wp cli 'mostly' doesn't look in extension-command/src/Plugin_Command.php Lines 816 to 825 in f0cebef
But that seems to be for checking if the local version installed is higher than the listed version (not the other way around) and displaying the So for the problem of telling a user that a newer version exists but that they can't install it, more code should be added to this section which checks if there is a newer version inside [no_update], and if so will check requires_php and requires with the assumption that one of them won't pass. Then my question would be, how to we display that to a user? Just a warning in the already existing The overall problem to fix here is the same regardless: how to update the wp cli interface to communicate various aspects of php/wp requirements and when they affect what a user can do. This also brings up how to display |
OK I think I understand my confusion. The original issue says:
And I said it doesn't, but it is true in the case of The wordpress.org API seems to filter responses based on the provided WordPress version in the headers, but not the PHP version (since WordPress doesn't send that to the wordpress.org API servers). So wp cli will show updates that don't pass Using the
So this should be addressed in wp cli in two places: wp cli needs to manually check the wp cli needs to also check that an update hasn't already been filtered into Then in both cases it can show an appropriate message that while there is a new upstream version, that update isn't available because of missing requirements |
I put up #440 which should fix this issue. I included the specific example in the original report as one of the new test cases |
The following command can be used to list out plugin updates:
but it includes plugins which are incompatible with the current site, due to either the
requires
orrequires_php
field values.It would be helpful to be able to add the following fields to the output if supported:
The update API appears to only return
requires
for no-update plugins and not therequires_php
/tested
/requires_plugins
(this can be fixed) but expanding the data would be helpful.It would additionally be useful to be able to filter plugins based on those fields, such as
--update=available --canbeinstalled
or something of the sort, for example, if a plugin requires PHP 8 but I'm running PHP 7.4 I don't want it included. I don't know how best to achieve that.The text was updated successfully, but these errors were encountered: