Skip to content

Document all accepted fields for the catch-all write commands - #636

Open
swissspidy wants to merge 3 commits into
mainfrom
claude/wp-cli-issue-5286-n50evd
Open

Document all accepted fields for the catch-all write commands#636
swissspidy wants to merge 3 commits into
mainfrom
claude/wp-cli-issue-5286-n50evd

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 16, 2026

Copy link
Copy Markdown
Member

Opened to make the documentation side of wp-cli/wp-cli#5286 concrete. Pairs with wp-cli/wp-cli#6392, which adds the typo detection itself — but this PR stands on its own and is useful without it.

Why this first

Every approach discussed on #5286 needs the same foundation: an accurate list of what each command actually accepts. Typo detection matches an unknown argument against the documented ones, so an incomplete docblock means either missed typos or false positives. comment update documented no fields at all.

On its own this PR does not change validation. The catch-all still suppresses unknown-parameter checking, so the added parameters only improve wp help output today. They are what gives the matcher something accurate to work with.

Where the lists come from

The wp_insert_user(), wp_insert_post() and wp_update_comment() docblocks in core trunk, rather than the 2019 list on the issue — that one predates user_activation_key / spam (5.3) and meta_input (5.9).

Command Added
user update syntax_highlighting, comment_shortcuts, admin_color, use_ssl, user_activation_key, spam, show_admin_bar_front, locale, meta_input
post create page_template, import_id
post update page_template
comment create full column set (15 fields; previously catch-all only)
comment update full column set (15 fields; previously none)

Two changes that are not documentation

Flagged separately because they are easy to drop if you'd rather keep this PR pure.

  1. user application-password update advertised --<field>=<value> while its own text said only name was supported. Core's WP_Application_Passwords::update_application_password() only ever reads $update['name'], so extra keys were silently ignored. Replaced the catch-all with [--name=<name>]. That command is now validated immediately, without depending on the framework PR.

  2. --meta_input and --comment_meta take arrays, so they go through Utils\parse_shell_arrays() the way Post_Command::update() already does. Without it a JSON value reaches core as a string. Documenting them without this would have meant documenting parameters that don't work.

The second one originally tripped PHPStan, because parse_shell_arrays() was annotated array<string, string> while Comment_Command correctly declares array<string, mixed>. That turned out to be an upstream annotation bug and is fixed in wp-cli/wp-cli#6393, so all four call sites in this repo are now the same plain one-liner. No release is needed for that — composer.json sets minimum-stability: dev and requires ^3.0, which resolves to dev-main.

Verification

comment_author_IP and comment_post_ID are mixed-case, so they depend on #6388. Against the parser before that fix they register truncated:

!! TRUNCATED: --comment_author_ parsed from <comment_author_IP>

Against current main all seven commands parse cleanly, with no truncated names and no unknown tokens:

user update                         assoc=21  flags=1  generic=1
post create                         assoc=28  flags=2  generic=1
post update                         assoc=26  flags=1  generic=1
comment create                      assoc=15  flags=1  generic=1
comment update                      assoc=15  flags=0  generic=1
user application-password update    assoc=1   flags=0  generic=0

Two things I noticed but did not change

Both are pre-existing and orthogonal, and both now have tests and fixes in #637.

  • post update --post_modified / --post_modified_gmt are documented but ignored. wp_insert_post() computes both itself and never reads them from $postarr.
  • user create documents --user_nicename and --rich_editing but never applies them. User_Command::create() builds an explicit stdClass and neither property is set. That command has no catch-all, so it is strictly validated and still silently drops the value — the same failure as #5286, from the other direction.

🤖 Generated with Claude Code

https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL

Summary by CodeRabbit

  • Documentation

    • Expanded comment command documentation with supported fields for creating and updating comments.
    • Documented additional post options, including page templates and import IDs.
    • Clarified user application password updates with a dedicated name option.
    • Added documentation for more user update fields, including preferences, status, locale, and metadata.
  • Bug Fixes

    • Improved handling of shell-array metadata when creating or updating comments and users.

`user update`, `post create`, `post update`, `comment create` and
`comment update` accept `--<field>=<value>`, and their documented field lists
have drifted from what core actually accepts. `comment update` documented no
fields at all.

Fill the lists in from the wp_insert_user(), wp_insert_post() and
wp_update_comment() docblocks in core:

- user update: syntax_highlighting, comment_shortcuts, admin_color, use_ssl,
  user_activation_key, spam, show_admin_bar_front, locale, meta_input
- post create: page_template, import_id
- post update: page_template
- comment create / comment update: the full column set, including the
  mixed-case comment_author_IP and comment_post_ID

Two related changes:

- `user application-password update` advertised `--<field>=<value>` while
  documenting that only `name` is supported. Core's
  WP_Application_Passwords::update_application_password() only ever reads
  `$update['name']`, so declare that parameter and drop the catch-all. The
  command is then validated without depending on anything else.

- `--meta_input` and `--comment_meta` take arrays, so run them through
  Utils\parse_shell_arrays() the way Post_Command::update() already does.
  Without it a JSON value reaches core as a string.

The new parameters have no effect on validation on their own, since the
catch-all still suppresses it. They are what gives typo detection something
accurate to match against.

Refs wp-cli/wp-cli#5286

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL
@coderabbitai

coderabbitai Bot commented Aug 16, 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: fd53f032-0cd5-47d6-9236-6546d10cd7ae

📥 Commits

Reviewing files that changed from the base of the PR and between 41a409d and 54c2ae5.

📒 Files selected for processing (4)
  • src/Comment_Command.php
  • src/Post_Command.php
  • src/User_Application_Password_Command.php
  • src/User_Command.php

Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The CLI documentation now lists additional comment, post, user, and application-password options. Comment and user update commands parse shell-array metadata before applying WordPress slashing and persistence.

Changes

CLI command updates

Layer / File(s) Summary
Comment fields and metadata handling
src/Comment_Command.php
Comment creation and update documentation lists supported fields and metadata. Both flows parse comment_meta before slashing and persistence.
Post and application-password options
src/Post_Command.php, src/User_Application_Password_Command.php
Post documentation lists page_template and import_id. Application-password documentation exposes the name option.
User update fields and metadata
src/User_Command.php
User update documentation lists additional fields and JSON meta_input. The update flow parses meta_input before calling wp_update_user.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 54c2a

This PR documents accepted command fields and corrects array parsing and application-password argument handling without introducing an identified merge-blocking risk; it is merge-ready after normal checks and review.

Possibly related PRs

Suggested labels: command:ability

Suggested reviewers: brianhenryie

🚥 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 clearly summarizes the main change: documenting accepted fields for catch-all write commands.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/wp-cli-issue-5286-n50evd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added command:comment-create Related to 'comment create' command command:comment-update Related to 'comment update' command command:post-create Related to 'post create' command labels Aug 16, 2026
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

PHPStan reported two errors on the calls added in the previous commit:

  Parameter #1 $assoc_args of function WP_CLI\Utils\parse_shell_arrays
  expects array<string, string>, array<string, mixed> given.

Utils\parse_shell_arrays() is annotated for string values throughout, while
Comment_Command's methods correctly declare their arguments as
array<string, mixed> - a flag arrives as true, not as a string.

Rather than weaken that annotation, hand the function only the one key it
needs to look at, and only when it holds a string. That is not a workaround
for the type checker: is_json() rejects anything that is not a string, so a
non-string value was never going to be parsed either way.

Post_Command makes the same call without complaint only because its
$assoc_args parameters carry no type at all, and missingType.parameter is in
the ignore list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL
wp-cli/wp-cli#6393 corrected parse_shell_arrays()'s $assoc_args parameter to
array<string, mixed>, which is what it always accepted. The local wrapper
existed only to work around the previous annotation, so revert to the plain
call and let all four call sites in this repo look the same again.

This does not need to wait for a wp-cli release: composer.json sets
minimum-stability to dev and requires ^3.0, which resolves to dev-main.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL
@swissspidy
swissspidy marked this pull request as ready for review August 16, 2026 15:34
@swissspidy
swissspidy requested a review from a team as a code owner August 16, 2026 15:34
Copilot AI lite review requested due to automatic review settings August 16, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

command:comment-create Related to 'comment create' command command:comment-update Related to 'comment update' command command:post-create Related to 'post create' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants