From 9cdaaf4124fe46bbfdcf984a50cbbfd8bf8d1e76 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:10:31 +0000 Subject: [PATCH 1/7] Initial plan From 3994b4d5c528e75f0a31cbf7227a6253ffefdf35 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:15:22 +0000 Subject: [PATCH 2/7] Improve downgrade message and add version info to up-to-date message Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/core-update.feature | 38 +++++++++++++++++++++++++++++++++++- src/Core_Command.php | 9 ++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/features/core-update.feature b/features/core-update.feature index a52bcd3b..30d28f57 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -167,7 +167,7 @@ Feature: Update WordPress core When I run `wp core update` Then STDOUT should contain: """ - WordPress is up to date + WordPress is up to date at version """ And STDOUT should not contain: """ @@ -384,3 +384,39 @@ Feature: Update WordPress core """ Success: """ + + @require-php-7.0 + Scenario: Attempting to downgrade without --force shows helpful message + Given a WP install + + When I run `wp core version` + Then save STDOUT as {WP_CURRENT_VERSION} + + When I try `wp core update --version=6.0` + Then STDOUT should contain: + """ + WordPress is up to date at version + """ + And STDOUT should contain: + """ + is older than the current version + """ + And STDOUT should contain: + """ + Use --force to update anyway + """ + And STDOUT should not contain: + """ + Success: + """ + And the return code should be 0 + + When I run `wp core update --version=6.0 --force` + Then STDOUT should contain: + """ + Updating to version 6.0 + """ + And STDOUT should contain: + """ + Success: WordPress updated successfully. + """ diff --git a/src/Core_Command.php b/src/Core_Command.php index b9bbb2b4..d61e706c 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1270,7 +1270,14 @@ public function update( $args, $assoc_args ) { WP_CLI::success( 'WordPress updated successfully.' ); } } else { - WP_CLI::success( 'WordPress is up to date.' ); + // Check if user attempted to downgrade without --force + if ( ! empty( $assoc_args['version'] ) && Utils\wp_version_compare( $assoc_args['version'], '>' ) ) { + WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); + WP_CLI::log( "The version you requested ({$assoc_args['version']}) is older than the current version ({$wp_version})." ); + WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version {$assoc_args['version']})." ); + } else { + WP_CLI::success( "WordPress is up to date at version {$wp_version}." ); + } } } From fcd7addfac2d553693c43fd8c3e5cdb81014b310 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:17:32 +0000 Subject: [PATCH 3/7] Fix version comparison logic for downgrade detection Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Core_Command.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index d61e706c..536502dd 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1271,7 +1271,8 @@ public function update( $args, $assoc_args ) { } } else { // Check if user attempted to downgrade without --force - if ( ! empty( $assoc_args['version'] ) && Utils\wp_version_compare( $assoc_args['version'], '>' ) ) { + if ( ! empty( $assoc_args['version'] ) && version_compare( $assoc_args['version'], $wp_version, '<' ) ) { + // Requested version is older than current (downgrade attempt) WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); WP_CLI::log( "The version you requested ({$assoc_args['version']}) is older than the current version ({$wp_version})." ); WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version {$assoc_args['version']})." ); From ad2183d6494c2e0bc81db183560a866cfa7f5e7f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 8 Nov 2025 11:14:14 +0100 Subject: [PATCH 4/7] Update src/Core_Command.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Core_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 536502dd..92e6edf4 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1274,7 +1274,7 @@ public function update( $args, $assoc_args ) { if ( ! empty( $assoc_args['version'] ) && version_compare( $assoc_args['version'], $wp_version, '<' ) ) { // Requested version is older than current (downgrade attempt) WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); - WP_CLI::log( "The version you requested ({$assoc_args['version']}) is older than the current version ({$wp_version})." ); + WP_CLI::log( "The version you requested (" . Utils\get_flag_value( $assoc_args, 'version' ) . ") is older than the current version ({$wp_version})." ); WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version {$assoc_args['version']})." ); } else { WP_CLI::success( "WordPress is up to date at version {$wp_version}." ); From 59ca578db82febab4e3c33f436b024979aeec1e4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 8 Nov 2025 11:14:23 +0100 Subject: [PATCH 5/7] Update src/Core_Command.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/Core_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 92e6edf4..217ddf50 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1271,11 +1271,11 @@ public function update( $args, $assoc_args ) { } } else { // Check if user attempted to downgrade without --force - if ( ! empty( $assoc_args['version'] ) && version_compare( $assoc_args['version'], $wp_version, '<' ) ) { + if ( ! empty( Utils\get_flag_value( $assoc_args, 'version' ) ) && version_compare( Utils\get_flag_value( $assoc_args, 'version' ), $wp_version, '<' ) ) { // Requested version is older than current (downgrade attempt) WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); WP_CLI::log( "The version you requested (" . Utils\get_flag_value( $assoc_args, 'version' ) . ") is older than the current version ({$wp_version})." ); - WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version {$assoc_args['version']})." ); + WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version " . Utils\get_flag_value( $assoc_args, 'version' ) . ")." ); } else { WP_CLI::success( "WordPress is up to date at version {$wp_version}." ); } From 7420d57d4b91fdc594a1f7aa0770ca2e99292910 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 15:57:40 +0100 Subject: [PATCH 6/7] Lint fixes --- src/Core_Command.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 217ddf50..658a11e4 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1269,16 +1269,14 @@ public function update( $args, $assoc_args ) { WP_CLI::success( 'WordPress updated successfully.' ); } - } else { // Check if user attempted to downgrade without --force - if ( ! empty( Utils\get_flag_value( $assoc_args, 'version' ) ) && version_compare( Utils\get_flag_value( $assoc_args, 'version' ), $wp_version, '<' ) ) { - // Requested version is older than current (downgrade attempt) - WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); - WP_CLI::log( "The version you requested (" . Utils\get_flag_value( $assoc_args, 'version' ) . ") is older than the current version ({$wp_version})." ); - WP_CLI::log( "Use --force to update anyway (e.g., to downgrade to version " . Utils\get_flag_value( $assoc_args, 'version' ) . ")." ); - } else { - WP_CLI::success( "WordPress is up to date at version {$wp_version}." ); - } + } elseif ( ! empty( Utils\get_flag_value( $assoc_args, 'version' ) ) && version_compare( Utils\get_flag_value( $assoc_args, 'version' ), $wp_version, '<' ) ) { + // Requested version is older than current (downgrade attempt) + WP_CLI::log( "WordPress is up to date at version {$wp_version}." ); + WP_CLI::log( 'The version you requested (' . Utils\get_flag_value( $assoc_args, 'version' ) . ") is older than the current version ({$wp_version})." ); + WP_CLI::log( 'Use --force to update anyway (e.g., to downgrade to version ' . Utils\get_flag_value( $assoc_args, 'version' ) . ').' ); + } else { + WP_CLI::success( "WordPress is up to date at version {$wp_version}." ); } } From 3dc28ece544ccc3fb7220ae1971d2dc11508f54a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 15:59:21 +0100 Subject: [PATCH 7/7] Adjust test --- features/core-update.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/core-update.feature b/features/core-update.feature index 30d28f57..f5cc14ab 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -385,7 +385,7 @@ Feature: Update WordPress core Success: """ - @require-php-7.0 + @require-php-7.0 @require-wp-6.1 Scenario: Attempting to downgrade without --force shows helpful message Given a WP install