Skip to content

Deprecate legacy back_compat_conversions syntaxes#6356

Open
schlessera wants to merge 3 commits into
mainfrom
fix/deprecate-back-compat-conversions
Open

Deprecate legacy back_compat_conversions syntaxes#6356
schlessera wants to merge 3 commits into
mainfrom
fix/deprecate-back-compat-conversions

Conversation

@schlessera

@schlessera schlessera commented Jul 21, 2026

Copy link
Copy Markdown
Member

Fixes #6353.

What

Runner::back_compat_conversions() silently rewrites a set of pre-1.0 command and flag syntaxes to their modern equivalents. This adds a deprecation warning at each genuinely-legacy conversion site, naming the modern form, while keeping the rewrite working. These syntaxes are scheduled for removal in 4.0.

Why

Nothing ever warned about these rewrites, so a user still on an old syntax has no signal that it is outdated. Removing them outright in 3.0 (the original plan) would break scripts with a bare "unknown command" and no pointer to the replacement, for syntaxes we never told anyone were deprecated. Deprecating in 3.0 and removing in 4.0 starts the clock at the major boundary, which is the first time we have ever signalled these are on the way out.

Deprecated in 3.0 (warn, keep working; remove in 4.0)

wp sql, wp blog, wp {post|comment|user|network}-meta, wp cli aliases, wp core config, wp core language, wp checksum core, wp checksum plugin, --admin_name, --site_id, wp {plugin|theme} update-all, wp transient delete-expired, wp transient delete-all, wp plugin scaffold, {post|user} list --ids, and wp {post|comment|site|term} url.

Each emits, for example:

WP-CLI: The 'wp sql' syntax is deprecated and will be removed in WP-CLI 4.0. Use 'wp db' instead.

Left untouched (permanent features, not legacy)

Per #6353 these stay as they are, with no warning:

  • wp <command> --help -> wp help <command> (this is how --help is implemented)
  • wp --version / wp --info -> wp cli version / wp cli info
  • --json -> --format=json (kept as a convenient shorthand)
  • Windows PowerShell space-separated numeric ID splitting

Implementation note

The conversion runs during the ConfigureRunner bootstrap step, which is before InitializeLogger, so WP_CLI::warning() would be lost at that point. The notice is therefore written straight to STDERR through a small deprecated_syntax() helper, matching the existing --blog deprecation in Configurator.

Out of scope

back_compat_conversions() also rewrites config get --global/--constant and bare config get -> config list. That one was not part of #6353's list, so it is deliberately left alone here. Worth a separate decision on whether to deprecate it too.

Tests

  • New features/back-compat.feature covers a deprecated top-level alias, a deprecated subcommand, a deprecated flag, and asserts a retained shorthand (--version) does not warn.
  • The existing wp cli aliases scenarios in features/aliases.feature now also assert the deprecation notice.
  • wp core config usages in features/config.feature and features/validation.feature switch to wp config create so they are not testing (and warning on) the deprecated alias.

Follow-up

The 4.0 removal (turning these into hard errors) is tracked as a task in #6353.

Summary by CodeRabbit

  • New Features

    • Added standardized deprecation warnings for legacy WP-CLI command and flag syntax, emitted to STDERR with guidance to the modern equivalent.
  • Bug Fixes

    • Deprecated aliases and shorthand forms now consistently report deprecation warnings via STDERR.
    • Confirmed supported shorthand such as wp --version remains warning-free.
  • Tests

    • Expanded backward-compatibility and conversion coverage to assert the new STDERR warnings across relevant deprecated command/flag scenarios, plus updated validation and config-related scenarios.

Runner::back_compat_conversions() silently rewrites a set of pre-1.0
command and flag syntaxes to their modern equivalents. Nothing ever
warned about them, so a user on the old syntax has no signal that it is
outdated.

Emit a deprecation warning naming the modern form at each legacy
conversion site, while keeping the rewrite working. These syntaxes are
scheduled for removal in 4.0. The warning is written directly to STDERR
(like the existing --blog deprecation in Configurator), because the
conversion runs during the ConfigureRunner bootstrap step, before the
logger is initialized.

The genuinely-permanent shorthands are left untouched: --help,
--version/--info, --json, and the Windows PowerShell numeric-ID splitting.

Existing tests that used deprecated forms are updated: the `wp cli
aliases` scenarios now also assert the deprecation notice, and the
`wp core config` usages switch to `wp config create`.
@schlessera schlessera added this to the 3.0.0 milestone Jul 21, 2026
@schlessera schlessera added the command:cli Related to 'cli' command label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 42caa463-d4a0-4166-881c-26ce6425b1c3

📥 Commits

Reviewing files that changed from the base of the PR and between 058c2dd and de4fc31.

📒 Files selected for processing (2)
  • features/config.feature
  • features/validation.feature

📝 Walkthrough

Walkthrough

Legacy WP-CLI command and flag rewrites now emit standardized deprecation warnings to STDERR while preserving existing conversions. Feature coverage verifies warnings, retained output, supported shorthand behavior, and modern config create usage.

Changes

Legacy syntax deprecation

Layer / File(s) Summary
Conversion warnings
php/WP_CLI/Runner.php
Legacy command and flag conversions now report the old and modern syntax to STDERR before rewriting arguments.
Warning and compatibility coverage
features/back-compat.feature, features/aliases.feature, features/runcommand.feature
Feature scenarios verify deprecation messages, preserved YAML/JSON output, quiet retained shorthand usage, and command execution handling.
Modern configuration command coverage
features/config.feature, features/validation.feature
Configuration creation and validation scenarios now use wp config create instead of wp core config.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: swissspidy

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Runner
  participant STDERR
  participant Command
  CLI->>Runner: invoke legacy command or flag syntax
  Runner->>STDERR: emit deprecation warning
  Runner->>Command: dispatch rewritten modern syntax
  Command-->>CLI: return existing command output
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: deprecating legacy back_compat_conversions syntaxes.
Linked Issues check ✅ Passed The PR adds warnings and tests for the legacy syntax rewrites required by #6353 while keeping command behavior intact.
Out of Scope Changes check ✅ Passed No obvious unrelated changes appear; the modified features and Runner logic all support the deprecation work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deprecate-back-compat-conversions

Comment @coderabbitai help to get the list of available commands.

@schlessera
schlessera marked this pull request as ready for review July 21, 2026 14:59
@schlessera
schlessera requested a review from a team as a code owner July 21, 2026 14:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@features/back-compat.feature`:
- Around line 8-46: Expand features/back-compat.feature with Behat scenarios
covering the newly warned conversions: *-meta, --admin_name, core language,
checksum aliases, --site_id, transient aliases, plugin scaffold, and URL
shortcuts. For each, assert the deprecation warning plus successful
rewritten-command output and exit behavior, and add warning-free coverage for
--help, --info, and --json while preserving the existing shorthand behavior
checks.

In `@features/config.feature`:
- Around line 212-214: Update the fixture key from “core config” to “config
create” so Runner::run_command() applies the extra-php configuration to the
renamed command. Add a separate legacy “wp core config” scenario that verifies
the deprecation warning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d49ee7a-8388-4aeb-928a-63f7852396b2

📥 Commits

Reviewing files that changed from the base of the PR and between 63fb80e and a0532ec.

📒 Files selected for processing (5)
  • features/aliases.feature
  • features/back-compat.feature
  • features/config.feature
  • features/validation.feature
  • php/WP_CLI/Runner.php

Comment on lines +8 to +46
Scenario: A deprecated top-level command alias warns
Given an empty directory

When I try `wp sql`
Then STDERR should contain:
"""
The 'wp sql' syntax is deprecated and will be removed in WP-CLI 4.0. Use 'wp db' instead.
"""

Scenario: A deprecated subcommand syntax warns
Given an empty directory

When I try `wp plugin update-all`
Then STDERR should contain:
"""
The 'wp plugin update-all' syntax is deprecated and will be removed in WP-CLI 4.0. Use 'wp plugin update --all' instead.
"""

Scenario: A deprecated flag warns
Given an empty directory

When I try `wp post list --ids`
Then STDERR should contain:
"""
The '--ids' syntax is deprecated and will be removed in WP-CLI 4.0. Use '--format=ids' instead.
"""

Scenario: Retained shorthands are not treated as deprecated
Given an empty directory

When I run `wp --version`
Then STDOUT should contain:
"""
WP-CLI
"""
And STDERR should not contain:
"""
is deprecated
"""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Expand acceptance coverage for the deprecation contract.

These scenarios do not cover newly warned conversions such as *-meta, --admin_name, core language, checksum aliases, --site_id, transient aliases, plugin scaffold, and URL shortcuts. The existing warning cases also mostly run in an empty directory and only assert STDERR, so they do not verify that the rewritten command still executes successfully. Add Behat scenarios for each conversion and assert retained output/exit behavior, plus warning-free --help, --info, and --json cases.

As per coding guidelines, features/**/*.feature: Add Behat acceptance tests for every new feature and bug fix, following existing feature-test patterns.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@features/back-compat.feature` around lines 8 - 46, Expand
features/back-compat.feature with Behat scenarios covering the newly warned
conversions: *-meta, --admin_name, core language, checksum aliases, --site_id,
transient aliases, plugin scaffold, and URL shortcuts. For each, assert the
deprecation warning plus successful rewritten-command output and exit behavior,
and add warning-free coverage for --help, --info, and --json while preserving
the existing shorthand behavior checks.

Source: Coding guidelines

Comment thread features/config.feature
Comment on lines +212 to 214
When I run `wp config create --skip-check`
And I run `grep WP_POST_REVISIONS wp-config.php`
Then STDOUT should not be empty

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Update the command-specific config key with the command rename.

The fixture still defines core config: at Lines [204-210], but this scenario now runs wp config create. Runner::run_command() looks up extra configuration by the resolved command name, so the extra-php block may not be applied and the subsequent grep WP_POST_REVISIONS assertion can fail. Rename the fixture key to config create:; add a separate legacy wp core config scenario to test the deprecation warning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@features/config.feature` around lines 212 - 214, Update the fixture key from
“core config” to “config create” so Runner::run_command() applies the extra-php
configuration to the renamed command. Add a separate legacy “wp core config”
scenario that verifies the deprecation warning.

The "Apply backwards compat conversions" scenario in runcommand.feature
runs `term url` through `wp run`, which now emits a deprecation notice on
STDERR; assert the notice instead of expecting empty STDERR, and use
`try` so the notice does not fail the step.

The `core config` config-section scenario keeps using `wp core config`
(so the `core config:` config key still matches) and switches to `try`
to tolerate the notice. Revert the validation scenarios back to
`wp core config`, which already used `try`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@features/config.feature`:
- Line 212: In the scenario around the “When I try `wp core config
--skip-check`” step, add the existing command-success assertion immediately
afterward and before the following grep command, preserving the return-code 0
check so failures cannot be masked.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2bf184ad-82bd-4773-b9c8-b83fc4be72ba

📥 Commits

Reviewing files that changed from the base of the PR and between a0532ec and 058c2dd.

📒 Files selected for processing (2)
  • features/config.feature
  • features/runcommand.feature

Comment thread features/config.feature Outdated
Rather than keeping the `core config` deprecated form and switching to
`try` to swallow the new notice, update these scenarios to the modern
`config create` command. The config-section scenario also renames its
wp-cli.yml key from `core config:` to `config create:` so the
command-specific config still matches, letting the step stay on
`When I run` and keep asserting a clean STDERR.

The runcommand "Apply backwards compat conversions" scenario keeps using
the deprecated `term url` form on purpose, since testing the conversion
(and now its notice) is the point of that scenario.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 39.13043% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Runner.php 39.13% 14 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli Related to 'cli' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate legacy back_compat_conversions syntaxes in 3.0.0, remove in 4.0.0

2 participants