Require --major for cross-major wp cli update#6355
Conversation
By default `wp cli update` offered the newest available release of any type, so it would jump across a major version boundary automatically. That can silently move a user onto a major that drops support for their PHP version or changes behavior. Keep the update within the current major version by default. A major update is only applied when `--major` is passed explicitly. When a major update is available but withheld, announce it and point at the `--major` flag so the jump stays a deliberate choice. The `--stable` and `--nightly` channels are unchanged, since they are an explicit request for a specific build. The selection logic is extracted into `select_update_offer()` and covered by unit tests.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Just noting/clarifying that we have PHP version requirement checks in place (using the manifest.json file) to avoid such surprises. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What
By default,
wp cli updateno longer crosses a major version boundary. A major update is only performed when--majoris passed. When a major update is available but withheld, the command announces it and names the--majorflag.Why
Today
wp cli updatepicks the newest available release of any type, so a user on 2.x is automatically offered (and with--yes, moved to) the next major. A major can raise the minimum PHP version or change behavior, so an unattendedwp cli updateshould not step across that line on its own. Requiring--majormakes crossing a major a deliberate choice, while routinewp cli updatekeeps a user current within their major.This is a deliberate behavior change for 3.0.0.
Behavior
Before, on 2.12.0 with 3.0.0 available:
After:
Within-major updates (minor and patch) work exactly as before with no flag.
Scope
--stableand--nightlyare unchanged. They are an explicit request for a specific channel or build, not the default "is there an update?" path.wp cli check-updatestill lists all available updates, including majors. This PR only changes which update the defaultwp cli updatewill apply.Implementation
The version-selection logic is pulled out of
update()intoselect_update_offer(), which excludes a major update unless it has been requested and reports a withheld major separately so the caller can hint at--major. This keeps the network fetch (get_updates()) and the selection policy apart, and makes the policy unit-testable.Tests
tests/CLICommandTest.phpgains unit tests forselect_update_offer(): the default skips a major and picks the newest minor/patch, falls back to patch when there is no minor,--majoroffers the major, a lone major is withheld with a hint, and an unavailable major produces no hint.