core-command
core-command copied to clipboard
Add `wp core check-update-db` command
- [x] Add
check-update-dbmethod to Core_Command class - [x] Implement logic to check if database update is needed (compare wp_db_version with current db_version)
- [x] Add support for --network flag for multisite installations
- [x] Add appropriate WP-CLI output messages
- [x] Update composer.json to register the new command
- [x] Create Behat feature tests for the new command
- [x] Address PR feedback:
- [x] Revert README.md (auto-generated file)
- [x] Fix composer.json semver version range
- [x] Fix code formatting alignment
- [x] Request code review and security scan (both passed with no issues)
Summary
Successfully implemented wp core check-update-db command that checks whether a WordPress database update is needed. The command:
- Returns exit code 1 when update is needed, 0 when database is up to date
- Compares
wp_db_versionwith currentdb_versionoption - Supports
--networkflag to check all sites in a multisite installation - Follows the same patterns as existing
wp core check-updatecommand - Includes comprehensive Behat tests for single site and multisite scenarios
All PR feedback has been addressed.
Original prompt
This section details on the original issue you should resolve
<issue_title>Improve DB update commands</issue_title> <issue_description>We currently have a command
wp core update-dbthat sometimes needs to be run after an update of Core.It would be great to have a mechanism to check whether an update is actually needed.
Also, both commands might make more sense as
wp db ...commands, instead ofwp core ...commands.Suggestion:
wp db check-update Checks for the need for WordPress database updates. wp db update Runs the WordPress database update procedure.Related issue: https://github.com/wp-cli/wp-cli/issues/5085
cc @swissspidy </issue_description>
<agent_instructions>The new command should be
wp core check-update-db, to align withwp core check-update</agent_instructions>Comments on the Issue (you are @copilot in this section)
- Fixes wp-cli/core-command#293
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.