Skip to content

Commit 55638a1

Browse files
committed
Treat older plugin no-update versions as up to date
1 parent 437e645 commit 55638a1

3 files changed

Lines changed: 40 additions & 54 deletions

File tree

features/plugin-update.feature

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Feature: Update WordPress plugins
240240

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

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

257-
When I try `wp plugin update --all`
258-
Then STDERR should contain:
259-
"""
260-
Warning: health-check: version higher than expected.
261-
"""
262-
263-
And STDOUT should not contain:
264-
"""
265-
Error: Only updated 1 of 1 plugins.
266-
"""
267-
257+
When I run `wp plugin update --all`
258+
Then STDERR should be empty
268259
And STDOUT should contain:
269260
"""
270-
Success: Updated 1 of 1 plugins (1 skipped).
261+
Success: Updated 1 of 1 plugins.
271262
"""
272263

273264
# Tests for --auto-update-indicated feature

features/plugin.feature

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -731,56 +731,58 @@ Feature: Manage WordPress plugins
731731
| db-error.php | | Custom database error message. | db-error.php |
732732

733733
@require-wp-4.0
734-
Scenario: Validate installed plugin's version.
735-
Given a WP installation
736-
And I run `wp plugin uninstall --all`
737-
And I run `wp plugin install hello-dolly --force`
738-
And a wp-content/mu-plugins/test-plugin-update.php file:
734+
Scenario Outline: Treat an older or empty no-update version as up to date
735+
Given a WP install
736+
And a wp-content/plugins/example/example.php file:
739737
"""
740738
<?php
741739
/**
742-
* Plugin Name: Test Plugin Update
743-
* Description: Fakes installed plugin's data to verify plugin version mismatch
744-
* Author: WP-CLI tests
740+
* Plugin Name: Example Plugin
741+
* Version: 2.0.0
745742
*/
743+
"""
744+
And that HTTP requests to https://api.wordpress.org/plugins/update-check/1.1/ will respond with:
745+
"""
746+
HTTP/1.1 200 OK
746747
747-
add_filter( 'site_transient_update_plugins', function( $value ) {
748-
if ( ! is_object( $value ) ) {
749-
return $value;
748+
{
749+
"plugins": [],
750+
"translations": [],
751+
"no_update": {
752+
"example/example.php": {
753+
"id": "vendor.example/plugins/example",
754+
"slug": "example",
755+
"plugin": "example/example.php",
756+
"new_version": "<upstream_version>",
757+
"package": ""
750758
}
751-
752-
unset( $value->response['hello-dolly/hello.php'] );
753-
$value->no_update['hello-dolly/hello.php']->new_version = '1.5';
754-
755-
return $value;
756-
} );
757-
?>
759+
}
760+
}
758761
"""
759762

760-
When I run `wp plugin list --name=hello-dolly --field=version`
761-
Then save STDOUT as {PLUGIN_VERSION}
762-
763-
When I run `wp plugin list --name=hello-dolly --field=update_version`
764-
Then save STDOUT as {UPDATE_VERSION}
765-
766763
When I run `wp plugin list`
767764
Then STDOUT should be a table containing rows:
768-
| name | status | update | version | update_version | auto_update |
769-
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | {UPDATE_VERSION} | off |
765+
| name | status | update | version | update_version | auto_update |
766+
| example | inactive | none | 2.0.0 | | off |
770767

771-
When I try `wp plugin update --all`
772-
Then STDERR should be:
768+
When I run `wp plugin update --all`
769+
Then STDOUT should be:
773770
"""
774-
Warning: hello-dolly: version higher than expected.
775-
Error: No plugins updated.
771+
Success: Plugin already updated.
776772
"""
773+
And STDERR should be empty
777774

778-
When I try `wp plugin update hello-dolly`
779-
Then STDERR should be:
775+
When I run `wp plugin update example`
776+
Then STDOUT should be:
780777
"""
781-
Warning: hello-dolly: version higher than expected.
782-
Error: No plugins updated.
778+
Success: Plugin already updated.
783779
"""
780+
And STDERR should be empty
781+
782+
Examples:
783+
| upstream_version |
784+
| 1.0.0 |
785+
| |
784786

785787
Scenario: Only valid status filters are accepted when listing plugins
786788
Given a WP install

src/Plugin_Command.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,6 @@ protected function get_item_list() {
10331033
// Get info for all plugins that don't have an update.
10341034
$plugin_update_info = isset( $all_update_info->no_update[ $file ] ) ? $all_update_info->no_update[ $file ] : null;
10351035

1036-
// Check if local version is newer than what is listed upstream.
1037-
if ( null !== $plugin_update_info && version_compare( $details['Version'], $plugin_update_info->new_version, '>' ) ) {
1038-
$items[ $file ]['update'] = static::INVALID_VERSION_MESSAGE;
1039-
$items[ $file ]['requires'] = isset( $plugin_update_info->requires ) ? $plugin_update_info->requires : null;
1040-
$items[ $file ]['requires_php'] = isset( $plugin_update_info->requires_php ) ? $plugin_update_info->requires_php : null;
1041-
}
1042-
10431036
// If there is a plugin in no_update with a newer version than the local copy, it is either because:
10441037
// A: the plugins update API has already filtered it because the local WordPress version is too low
10451038
// B: It is possibly a paid plugin that has an update which the user does not qualify for

0 commit comments

Comments
 (0)