Repository navigation
REST API: Only let a reaction's author delete it - #15383
adamsilverstein wants to merge 4 commits into
Conversation
A reaction speaks for its author, so being able to edit the note's post is no longer enough to remove someone else's. Reactions on a resolved thread are also frozen for deletion, matching the existing check on create. The thread-root walk moves into a shared is_thread_resolved() helper. This brings over the PHP changes from WordPress/gutenberg#85415. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018vwYjTXU324rGneSjaye87
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
See #66447. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018vwYjTXU324rGneSjaye87
|
Code matches WordPress/gutenberg#85415 Retested the scenarios
|
| ); | ||
| } | ||
|
|
||
| if ( 'reaction' === $comment->comment_type ) { |
There was a problem hiding this comment.
Just checking, do we need to strtolower here for the same reasons as in WordPress/gutenberg#85883 (comment)
Mirrors check_edit_permission(), so a case-variant reaction type can't skip the author-only and resolved-thread checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since r65038, deleting a note reaction goes through the same `edit_comment` check as its note, so anyone who can edit the note's post, including the post author and administrators, could remove someone else's reaction. A reaction speaks for its author, so `WP_REST_Comments_Controller::delete_item_permissions_check()` now only allows its author to delete it. Reactions on a resolved thread also can no longer be deleted, matching the existing check in `create_item()`. The thread-root walk moves into a private `is_thread_resolved()` helper shared by both. The reaction type is matched case-insensitively, like in `check_edit_permission()`. Developed in: #15383 Developed in: WordPress/gutenberg#85415 Follow-up to r64488, r65038. Props adamsilverstein, ramonopoly, mamaduka. Fixes #66447. git-svn-id: https://develop.svn.wordpress.org/trunk@65222 602fd350-edb4-49c9-b593-d223f7449a82
Since r65038, deleting a note reaction goes through the same `edit_comment` check as its note, so anyone who can edit the note's post, including the post author and administrators, could remove someone else's reaction. A reaction speaks for its author, so `WP_REST_Comments_Controller::delete_item_permissions_check()` now only allows its author to delete it. Reactions on a resolved thread also can no longer be deleted, matching the existing check in `create_item()`. The thread-root walk moves into a private `is_thread_resolved()` helper shared by both. The reaction type is matched case-insensitively, like in `check_edit_permission()`. Developed in: WordPress/wordpress-develop#15383 Developed in: WordPress/gutenberg#85415 Follow-up to r64488, r65038. Props adamsilverstein, ramonopoly, mamaduka. Fixes #66447. Built from https://develop.svn.wordpress.org/trunk@65222 git-svn-id: http://core.svn.wordpress.org/trunk@64371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since r65038, deleting a note reaction goes through the same `edit_comment` check as its note, so anyone who can edit the note's post, including the post author and administrators, could remove someone else's reaction. A reaction speaks for its author, so `WP_REST_Comments_Controller::delete_item_permissions_check()` now only allows its author to delete it. Reactions on a resolved thread also can no longer be deleted, matching the existing check in `create_item()`. The thread-root walk moves into a private `is_thread_resolved()` helper shared by both. The reaction type is matched case-insensitively, like in `check_edit_permission()`. Developed in: WordPress#15383 Developed in: WordPress/gutenberg#85415 Follow-up to r64488, r65038. Props adamsilverstein, ramonopoly, mamaduka. Fixes #66447. git-svn-id: https://develop.svn.wordpress.org/trunk@65222 602fd350-edb4-49c9-b593-d223f7449a82
Claude put together this backport and its description:
Trac ticket: https://core.trac.wordpress.org/ticket/66447
AI Use
Ported from the Gutenberg PR with 🤖 Claude Code, code and description both. I will review and test.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code
https://claude.ai/code/session_018vwYjTXU324rGneSjaye87