From 6af207afb9c43c0b5c1476bea7c8f0d080f7305c Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 23 Jul 2026 05:39:05 +0200 Subject: [PATCH] Treat older plugin no-update versions as up to date --- features/plugin-update.feature | 17 ++------- features/plugin.feature | 70 +++++++++++++++++----------------- src/Plugin_Command.php | 7 ---- 3 files changed, 40 insertions(+), 54 deletions(-) diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 86c5f68c..3d65c0b9 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -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` @@ -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 diff --git a/features/plugin.feature b/features/plugin.feature index 5992e722..2d42f4a1 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -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: """ ", + "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 diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index c5b6f7dc..daefc893 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -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