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

Conversation

@thrijith
Copy link
Member

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 added some commits Mar 7, 2019

@thrijith

This comment has been minimized.

Copy link
Member Author

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 Mar 14, 2019

@thrijith thrijith requested a review from wp-cli/committers as a code owner Mar 14, 2019

@schlessera

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

@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

thrijith added some commits Mar 18, 2019

@schlessera
Copy link
Member

left a comment

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 added some commits Mar 21, 2019

@thrijith

This comment has been minimized.

Copy link
Member Author

commented Mar 21, 2019

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

@schlessera
Copy link
Member

left a comment

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'] ) ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Mar 21, 2019

Member

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.

@schlessera
Copy link
Member

left a comment

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

* Author: WP-CLI tests
*/
add_filter( 'site_transient_update_plugins', function( $value ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Mar 21, 2019

Member

I'm still not happy with the flow here, there's still a logical gap (you might have an existing $value->no_update['hello-dolly/hello.php'] and just keep it...).

I suggest rewriting this like so (and hope WP won't return even more nonsense in that filter):

add_filter( 'site_transient_update_plugins', function( $value ) {
    if ( ! is_object( $value ) ) {
        return $value;
    }

    unset( $value->response['hello-dolly/hello.php'] );
    $value->no_update['hello-dolly/hello.php']->new_version = '1.5';

    return $value;
} );
@schlessera

This comment has been minimized.

Copy link
Member

commented Mar 30, 2019

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@schlessera schlessera added this to the 2.0.4 milestone Mar 30, 2019

@thrijith thrijith deleted the thrijith:feature/add-plugin-source-alert branch Apr 2, 2019

@wonderWomantotheResue

This comment has been minimized.

Copy link

commented May 2, 2019

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
3 participants
You can’t perform that action at this time.