You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WordPress#12311 and WordPress#12310 are on WordPress/wordpress-develop; the rest are fork PRs targeting their parent branch and will retarget to trunk as their base lands.
Claude re-checked the audit here, summary below:
What
wp_ajax_dim_comment() (approve/unapprove from the comments list table) now falls back to the per-comment moderate_comment meta capability instead of the global moderate_comments primitive. A moderator of a custom comment type can then approve and unapprove that type's comments from the list table, and a global moderator no longer gets a pass on a type with its own capability model.
Why
Follow up to #56, same idea on the admin side. Before this change a moderate_reviews user couldn't dim review comments, while any moderate_comments user could dim every type. See https://core.trac.wordpress.org/ticket/35214
For the default capability model moderate_comment resolves to moderate_comments, so comment, pingback, trackback, note, reaction and unregistered types behave exactly as before.
How
src/wp-admin/includes/ajax-actions.php - wp_ajax_dim_comment() checks edit_comment first, as before, then current_user_can( 'moderate_comment', $comment->comment_ID ).
This looks like the last admin-side per-comment moderation gate on the bare primitive. wp-admin/comment.php, edit-comments.php, the other AJAX handlers, list table row actions and XML-RPC wp.editComment already use edit_comment, which #55 made type-aware. The remaining moderate_comments checks are either collection-level (list table bulk actions, Empty Spam/Trash, XML-RPC wp.getComments status filter) or creation-time checks on the commenter (flood bypass, moderator auto-approve), so there's no single comment to check against.
Testing
tests/phpunit/tests/ajax/wpAjaxDimComment.php registers a review type with capability_type => review and covers:
A moderate_reviews user can dim (approve) and un-dim (unapprove) a review comment.
A global moderate_comments user without the type's caps gets -1 on a review comment.
A review moderator gets -1 on a default comment.
A global moderator can still dim unregistered (webmention), note and reaction comments.
To try it by hand, register a review type with capability_type => review, give a subscriber moderate_reviews, edit_others_reviews and edit_posts so they can reach the comments screen, then approve/unapprove a review comment from the list.
Out of scope / follow-ups
Creation-time checks (wp_check_comment_flood() bypass and wp_allow_comment() auto-approve) still look at moderate_comments for the commenting user. Worth a look once comment creation knows about types.
Claude Code wrote the change, tests, and this description. I will review and test.
Summary by CodeRabbit
Bug Fixes
Comment moderation now checks permissions for the specific comment type. Moderators with the appropriate type-specific capability can approve or unapprove those comments, while permissions for standard comments and other types remain separate.
`wp_ajax_dim_comment()` fell back to the global `moderate_comments`
primitive when a user could not `edit_comment` the target comment, so a
moderator of a custom comment type could not approve or unapprove comments
of that type from the admin list table.
Route the fallback through the per-comment `moderate_comment` meta
capability. For comment types using the default capability model this
resolves to `moderate_comments` (behavior unchanged); a type with its own
capabilities is gated by its own moderation primitive.
This is the last per-comment moderation gate in the admin AJAX path. The
remaining `moderate_comments` checks in the list table (bulk action
availability, the Empty Spam/Trash button) and in XML-RPC `wp.getComments`
are collection-level, not per-comment, and intentionally stay global.
See #35214.
Drive `wp_ajax_dim_comment()` through the Ajax test harness: a moderator of
an independent `review` type can dim its comments, while a global
`moderate_comments` moderator without the type's capabilities is denied. The
existing administrator and subscriber tests continue to pass, confirming the
default model is unchanged.
See #35214.
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 57f57853-e739-4b47-a020-91d3924a0936
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The dim-comment AJAX action now checks edit_comment or moderate_comment for the target comment. Tests cover approval and unapproval permissions for registered, unregistered, and default comment types.
Changes: Comment moderation
Layer / File(s)
Summary
Dim-comment authorization and coverage src/wp-admin/includes/ajax-actions.php, tests/phpunit/tests/ajax/wpAjaxDimComment.php
The AJAX action uses the comment-specific moderate_comment capability instead of the general moderate_comments capability as its alternative authorization check. The tests cover type-specific moderation, global moderation, and default comment behavior.
The authorization change appears ready to merge after the reported test commands are run; their results were not supplied.
Security architecture risk: Low · up to ddd60
The change preserves comment-specific permission checks and nonce protection. However, newly authorized type-only moderators also receive broader moderation-count metadata through the existing response handler. The exposure is limited to aggregate counts, but its intended visibility should be clarified.
Retained concerns
Low · security · observed: Newly authorized type-only moderators inherit unscoped moderation-count visibility. The response exposes site-wide pending counts and can return totals for an unrelated post selected through the submitted URL, without checking authority over that post. The same moderation-only principal was denied this path at the PR base. This broadens metadata access beyond the target-type operation; whether that sharing is intentional remains unresolved.
Security review details
Security Blast Radius
observed — The moderation primitive is type-wide, not limited to comments authored by the caller or posts the caller can edit. The mutation targets the authorized comment, but response metadata includes broader site-level counts and potentially unrelated-post totals.
Security Findings and Attack Paths
observed — A subscriber granted only moderate_reviews can now moderate an eligible review comment with a valid nonce and receive the helper’s global pending count. Submitted pagination fields and an unrelated p parameter can also select another post’s aggregate totals. The inspected response returns aggregate metadata, not unrelated comment bodies; the confidentiality policy for these counts is unspecified.
Trust Boundaries and Controls
observed — Capability selection uses the stored comment type rather than a submitted type. Missing comment arguments or nonexistent comments map to do_not_allow. The action retains its comment-bound nonce before writes; its earlier matching-status response performs no mutation.
Resilience and Maintainability Implications
inferred — Reusing the existing status writer preserves the prior failure and recovery behavior rather than introducing a new multi-step persistence protocol. Concurrency and interrupted-write guarantees were not demonstrated dynamically, and this PR does not add atomicity or retry protections.
Hardening Proposals
proposed — Define whether aggregate moderation metadata is shared with type-only moderators. If it should follow delegated authority, restrict response counts to authorized types and posts instead of accepting an unrelated post selector; otherwise make the broader metadata contract explicit.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: admin comment dimming becomes comment-type aware. The raw summary confirms the change to the wp_ajax_dim_comment() capability check and the added type-aware tests. The…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description follows the repository template closely. It links Trac ticket 66734 and includes the What, Why, How, Testing, and AI disclosure content. It also explains the stacked PR context and the…
Full details: Title check
Explanation
The title names the main change: admin comment dimming becomes comment-type aware. The raw summary confirms the change to the wp_ajax_dim_comment() capability check and the added type-aware tests. The title is specific, concise, and includes the Trac reference and stage marker, which are acceptable.
Full details: Description check
Explanation
The description follows the repository template closely. It links Trac ticket 66734 and includes the What, Why, How, Testing, and AI disclosure content. It also explains the stacked PR context and the scope boundary. Two gaps exist. The template asks for a description placed above the Trac line, and the AI Use section names the tool but not the model or the exact extent of AI authorship in the template format. The author states that Claude Code wrote the change and that the author will review and test. The description also contains a mismatch with the objectives. The description does not mention a 7.2.0 or 7.3.0 version change, yet the PR objectives say the commits update documented release versions to 7.2.0 and 7.3.0. The raw summary says the documented change is 7.3.0. The description also does not report test results. These gaps are minor, so the check passes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit checks the comment gate, For each type, it tests the state. Reviewers approve, then set it right, The proper checks now guide the byte. Soft paws hop off into the night.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: b225fedf-1c25-4f76-b6fe-aa42271036c5
Commits
Reviewing files that changed from the base of the PR and between b4f9139 and ddd60bc.
Files selected for processing: 2
src/wp-admin/includes/ajax-actions.php
tests/phpunit/tests/ajax/wpAjaxDimComment.php
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
- Add the missing @SInCE 7.1.0 changelog entry to wp_ajax_dim_comment()
and an inline rationale at the rerouted capability check, making the
pattern self-documenting at every rerouted site.
- Tests: the un-dim direction (dimming an approved comment unapproves
it) for a type moderator, the inverse denial (a type moderator cannot
dim a default-model comment), and the unregistered-type back-compat
pin (a global moderator retains control of never-registered types via
AJAX). Drop the cleanup-only unregister call now handled by the test
framework.
The `@since` entry named 7.1.0, but the change ships in 7.2.0, and the
inline comment restated what the meta capability mapping already
documents. No behavior change.
See #35214.
Trunk added the `reaction` type next to `note`. Neither registers its own
capabilities, so `moderate_comment` resolves to `moderate_comments` and
a global moderator can still dim them, as before. Pins that, and adds
native types to the new helpers and tests so they pass PHPStan level 10.
See #35214.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack: Custom Comment Types (#35214)
register_comment_type()registration API/wp/v2/comment-typesendpointmap_meta_cap()render_callbackdisplay callbackis_pingping groupingdefault_excluded_comment_typesfilterwp_update_comment_counts()recount helperWordPress#12311 and WordPress#12310 are on WordPress/wordpress-develop; the rest are fork PRs targeting their parent branch and will retarget to trunk as their base lands.
Claude re-checked the audit here, summary below:
Trac ticket: https://core.trac.wordpress.org/ticket/66734
See also: https://core.trac.wordpress.org/ticket/35214
AI Use
Claude Code wrote the change, tests, and this description. I will review and test.
Summary by CodeRabbit
Generated by Claude Code