Skip to content
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

Display warning in plugin list info if plugin version is higher than expected #157

Merged
merged 11 commits into from
Mar 30, 2019
Merged

Display warning in plugin list info if plugin version is higher than expected #157

merged 11 commits into from
Mar 30, 2019

Conversation

thrijith
Copy link
Member

@thrijith thrijith commented Mar 7, 2019

Fixes #142

+------------------+----------+---------------------------------------+---------+
| name             | status   | update                                | version |
+------------------+----------+---------------------------------------+---------+
| akismet          | inactive | This version is higher than expected! | 999     |
| woocommerce      | inactive | available                             | 3.4.5   |
+------------------+----------+---------------------------------------+---------+

Theme List

+-----------------+----------+---------------------------------------+---------+
| name            | status   | update                                | version |
+-----------------+----------+---------------------------------------+---------+
| custom-theme    | inactive | none                                  | 1.0.26  |
| twentynineteen  | inactive | This version is higher than expected! | 1.5     |
| twentyseventeen | active   | available                             | 2.0     |
| twentysixteen   | inactive | none                                  | 1.9     |
+-----------------+----------+---------------------------------------+---------+

@thrijith
Copy link
Member Author

thrijith commented Mar 7, 2019

PR is in draft as I couldn't find an any data of current theme version like plugin. For plugin that data is available in response's no_update . Is there any other option for theme?

@thrijith thrijith marked this pull request as ready for review March 14, 2019 17:39
@thrijith thrijith requested a review from a team as a code owner March 14, 2019 17:39
@schlessera
Copy link
Member

@thrijith The only thing I can think of right now is to go through the themes that state they don't provide an update and do an extra query to retrieve the latest version of these themes through the theme_information query:
Image 2019-03-16 at 11 23 48 PM

Copy link
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I flagged some mostly minor changes in here. The code in general looks good, but we need those tests to make sure it actually what we expect.

For testing, I think you're best bet is to assemble and load a small custom plugin snippet in Behat that uses the site_transient_update_plugins hook to modify the data that was retrieved from the API before running the command.

src/Plugin_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/WP_CLI/CommandWithUpgrade.php Outdated Show resolved Hide resolved
src/Plugin_Command.php Outdated Show resolved Hide resolved
src/Theme_Command.php Outdated Show resolved Hide resolved
src/Plugin_Command.php Outdated Show resolved Hide resolved
@thrijith
Copy link
Member Author

@schlessera I have added a test for verifying the change. Please check and let me know if something needs change.

Copy link
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small reliability improvement, and then we're good to merge.

*/

add_filter( 'site_transient_update_plugins', function( $value ) {
if ( isset( $value->no_update['hello-dolly/hello.php'] ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could potentially cause sporadic test failures where an update will be noticed after the installation step in line 555.

I think it would be better to do the following instead, without a prior check:

  • unset ( $value->response['hello-dolly/hello.php'] ); (in case an actual update was found)
  • $value->no_update['hello-dolly/hello.php']->new_version = '1.5'; to fake the versions as you already did.

This should always reliable trigger the error condition, if I've read the code correctly.

Copy link
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the back and forth, but I think there's still a logical flaw in there.

features/plugin.feature Show resolved Hide resolved
@schlessera
Copy link
Member

Alright, let's merge this version now. We'll probably soon find out if we forgot something else now...;)

Thanks for the PR!

@schlessera schlessera merged commit 7308987 into wp-cli:master Mar 30, 2019
@schlessera schlessera added this to the 2.0.4 milestone Mar 30, 2019
@thrijith thrijith deleted the feature/add-plugin-source-alert branch April 2, 2019 13:32
@wonderWomantotheResue
Copy link

Here's what I'm experiencing with wp cli v2.2.0 release 4/26. upon using wp theme list, I now see an error message next to themes by Elegant: MyResume, Minimal, Glow, and BlueSky. I see this:
versionhigherthanexpected

BlueSky | inactive | version higher than expected | 5.0.12 | network

this error message is a false positive. The Elegant theme Blue sky is on current level today, 5.0.12 and does not need updating. Yet, wp cli thinks it needs updating. It happens with 4 of the Elegant themes we have installed on multi site. Something is out of sync. Plus the legend for the new version of wp theme status does not include U -update Available.
themeStatus_Legend

However, regarding the legend missing the definition for U -update Available seems to be appear as expected today. It looks like it was fixed. I just ran wp theme status today and the U = Update Available now exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Plugin and Theme list should alert if the version is HIGHER than found on .org
3 participants