Repository navigation
Conversation
|
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. |
getsource
left a comment
There was a problem hiding this comment.
This looks good to me.
Tested this PR manually, and verified that it fixes the issue.
|
Tested on 7.2-beta3-64990 with real REST requests (cookie auth + nonce) and a Comment Moderator role that only has Before the patch the moderator gets a 200 and the reaction is deleted, even though the same user gets a 403 on the note it belongs to. With the patch it's a 403 and the reaction stays. Moderator on a regular comment, editor on their own and the admin's reaction, and contributor all behave the same before and after. Full results on the ticket: https://core.trac.wordpress.org/ticket/66406 |
|
Thanks for testing, folks! |
check_edit_permission() sends notes through edit_comment, which maps to edit_post on the note's post, but did not include reactions. A reaction now takes the same path as the note it belongs to. Reactions already cannot be updated, so only deleting one changes. Regular comments are unaffected. See #66406.
baeb44e to
1f0995a
Compare
What
Deleting a reaction through
/wp/v2/commentsnow uses the same permission check as the note it belongs to: edit access to the note's post.Why
Reactions were added in r64488 to use the note permission checks, and most of the controller already does.
check_edit_permission(), which decides who can delete a comment, sends notes throughedit_commentsince r64875 but doesn't include reactions yet. Deleting a reaction therefore falls back to the permission rules for regular comments. Reactions can't be updated, so deleting is the only action affected.What changed
WP_REST_Comments_Controller::check_edit_permission()treatsreactionthe same asnote.Manual testing
Give the Author role comment moderation:
npm run env:cli -- cap add author moderate_comments.As an Administrator, create a draft post and note its ID (
POST). In the block editor console, add a note, then a reaction to it (NOTEis the note's ID):Log in as an Author, open the editor on a post of your own, and delete the reaction (
REACTIONis its ID). This should return 403rest_cannot_delete. On trunk it returns 200.As the Administrator, run the same delete. It should return 200.
Undo step 1:
npm run env:cli -- cap remove author moderate_comments.Trac ticket: https://core.trac.wordpress.org/ticket/66406
Use of AI Tools
Claude to write 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.