Skip to content

Conversation

Copy link

Copilot AI commented Nov 7, 2025

Description

When attempting to downgrade WordPress without --force, the command incorrectly reported Success: WordPress is up to date. This was misleading—the installed version didn't change, and "up to date" doesn't describe refusing a downgrade.

Changes:

  • Detect downgrade attempts: Added logic to identify when requested version < current version
  • Informative messaging for blocked downgrades:
    • Uses WP_CLI::log() instead of WP_CLI::success() (not a success)
    • States current version explicitly
    • Explains requested version is older
    • Suggests --force flag
  • Enhanced up-to-date messages: All now include version number ("WordPress is up to date at version X.Y.Z")
  • Exit code preservation: Maintains exit code 0 for CI compatibility when downgrade blocked
  • Code consistency: Uses Utils\get_flag_value() helper throughout for safe array access, consistent with the rest of the codebase

Example output:

Before (downgrade attempt):

Success: WordPress is up to date.

After (downgrade attempt):

WordPress is up to date at version 5.1.
The version you requested (5.0.3) is older than the current version (5.1).
Use --force to update anyway (e.g., to downgrade to version 5.0.3).

Implementation:

// In Core_Command::update() method
if ( ! empty( Utils\get_flag_value( $assoc_args, 'version' ) ) && version_compare( Utils\get_flag_value( $assoc_args, 'version' ), $wp_version, '<' ) ) {
    // Requested version is older - 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}." );
}

Addresses #160

Original prompt

This section details on the original issue you should resolve

<issue_title>"wordpress is up to date" message displayed when attempting downgrade without --force</issue_title>
<issue_description>With a WordPress site on WordPress 5.1 that I want to downgrade to 5.0.3 for testing:

$ wp core update --version=5.0.3
Success: WordPress is up to date.

There are several problems with this message:

  • "Success" is wrong; the installed WordPress version did not change
  • "up to date" is not the desired outcome. Could this message be expanded to "Wordpress is up to date at version $version"?
  • When attempting to "upgrade" to a version older than the currently-installed version, wp core update doesn't explain to the user why the version was not updated. Some additional verbosity here would be appreciated: "Did not upgrade to 5.0.3 because the newer version 5.1 is already installed. retry with --force to ignore this check."

A solution to this problem might look like:

  • Do not display "Success" if the safety checks in wp core update abort an update
  • Display the installed version number in "WordPress is up to date" messages
  • When an "upgrade" to an older version is blocked by the presence of a newer version, output a message saying that that is the case, listing the newer version currently installed, and provide a "did you mean to --force?" message
The successful command, which is irrelevant to this issue The successful command was:
$ wp core update --version=5.0.3 --force
Updating to version 5.0.3 (en_US)...
Downloading update from https://wordpress.org/wordpress-5.0.3.zip...
Unpacking the update...
Cleaning up files...
File removed: wp-includes/ms-site.php
File removed: wp-includes/ms-network.php
File removed: wp-includes/js/backbone.js
File removed: wp-includes/js/underscore.js
File removed: wp-includes/js/codemirror/fakejshint.js
File removed: wp-includes/js/codemirror/esprima.js
6 files cleaned up.
Success: WordPress updated successfully.

Comments on the Issue (you are @copilot in this section)

@schlessera @benlk Your proposed solution sounds good to me, with one potential caveat:

Do not display "Success" if the safety checks in wp core update abort an update

I'm not sure off the top of my head whether we can actually differentiate between "is up-to-date, all good" and "is higher already, abort". And for the purposes of CI systems, we don't want a scenario of "is up-to-date, all good" to throw an error and stop the pipeline.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 7, 2025 22:15
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix misleading message when downgrading WordPress version Fix misleading "Success: WordPress is up to date" message when downgrade blocked Nov 7, 2025
Copilot AI requested a review from swissspidy November 7, 2025 22:24
Copilot finished work on behalf of swissspidy November 7, 2025 22:24
@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy requested a review from Copilot November 8, 2025 09:42

This comment was marked as resolved.

swissspidy and others added 2 commits November 8, 2025 11:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot finished work on behalf of swissspidy November 8, 2025 10:20
@swissspidy swissspidy marked this pull request as ready for review November 10, 2025 15:00
@swissspidy swissspidy requested a review from a team as a code owner November 10, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"wordpress is up to date" message displayed when attempting downgrade without --force

2 participants