Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions features/plugin-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Feature: Update WordPress plugins

# Skipped on Windows because of sed usage that would need to be refactored for compatibility.
@require-wp-5.2 @skip-windows
Scenario: Updating all plugins with some of them having an invalid version shouldn't report an error
Scenario: Updating all plugins ignores an older no-update version
Given a WP install
And I run `wp plugin delete akismet`

Expand All @@ -254,20 +254,11 @@ Feature: Update WordPress plugins
Then STDOUT should be empty
And the return code should be 0

When I try `wp plugin update --all`
Then STDERR should contain:
"""
Warning: health-check: version higher than expected.
"""

And STDOUT should not contain:
"""
Error: Only updated 1 of 1 plugins.
"""

When I run `wp plugin update --all`
Then STDERR should be empty
And STDOUT should contain:
"""
Success: Updated 1 of 1 plugins (1 skipped).
Success: Updated 1 of 1 plugins.
"""

# Tests for --auto-update-indicated feature
Expand Down
70 changes: 36 additions & 34 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -731,56 +731,58 @@ Feature: Manage WordPress plugins
| db-error.php | | Custom database error message. | db-error.php |

@require-wp-4.0
Scenario: Validate installed plugin's version.
Given a WP installation
And I run `wp plugin uninstall --all`
And I run `wp plugin install hello-dolly --force`
And a wp-content/mu-plugins/test-plugin-update.php file:
Scenario Outline: Treat an older or empty no-update version as up to date
Given a WP install
And a wp-content/plugins/example/example.php file:
"""
<?php
/**
* Plugin Name: Test Plugin Update
* Description: Fakes installed plugin's data to verify plugin version mismatch
* Author: WP-CLI tests
* Plugin Name: Example Plugin
* Version: 2.0.0
*/
"""
And that HTTP requests to https://api.wordpress.org/plugins/update-check/1.1/ will respond with:
"""
HTTP/1.1 200 OK

add_filter( 'site_transient_update_plugins', function( $value ) {
if ( ! is_object( $value ) ) {
return $value;
{
"plugins": [],
"translations": [],
"no_update": {
"example/example.php": {
"id": "vendor.example/plugins/example",
"slug": "example",
"plugin": "example/example.php",
"new_version": "<upstream_version>",
"package": ""
}

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

return $value;
} );
?>
}
}
"""

When I run `wp plugin list --name=hello-dolly --field=version`
Then save STDOUT as {PLUGIN_VERSION}

When I run `wp plugin list --name=hello-dolly --field=update_version`
Then save STDOUT as {UPDATE_VERSION}

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version | update_version | auto_update |
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | {UPDATE_VERSION} | off |
| name | status | update | version | update_version | auto_update |
| example | inactive | none | 2.0.0 | | off |

When I try `wp plugin update --all`
Then STDERR should be:
When I run `wp plugin update --all`
Then STDOUT should be:
"""
Warning: hello-dolly: version higher than expected.
Error: No plugins updated.
Success: Plugin already updated.
"""
And STDERR should be empty

When I try `wp plugin update hello-dolly`
Then STDERR should be:
When I run `wp plugin update example`
Then STDOUT should be:
"""
Warning: hello-dolly: version higher than expected.
Error: No plugins updated.
Success: Plugin already updated.
"""
And STDERR should be empty

Examples:
| upstream_version |
| 1.0.0 |
| |

Scenario: Only valid status filters are accepted when listing plugins
Given a WP install
Expand Down
7 changes: 0 additions & 7 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,13 +1033,6 @@ protected function get_item_list() {
// Get info for all plugins that don't have an update.
$plugin_update_info = isset( $all_update_info->no_update[ $file ] ) ? $all_update_info->no_update[ $file ] : null;

// Check if local version is newer than what is listed upstream.
if ( null !== $plugin_update_info && version_compare( $details['Version'], $plugin_update_info->new_version, '>' ) ) {
$items[ $file ]['update'] = static::INVALID_VERSION_MESSAGE;
$items[ $file ]['requires'] = isset( $plugin_update_info->requires ) ? $plugin_update_info->requires : null;
$items[ $file ]['requires_php'] = isset( $plugin_update_info->requires_php ) ? $plugin_update_info->requires_php : null;
}

// If there is a plugin in no_update with a newer version than the local copy, it is either because:
// A: the plugins update API has already filtered it because the local WordPress version is too low
// B: It is possibly a paid plugin that has an update which the user does not qualify for
Expand Down
Loading