Repository navigation
Notes: Only let a reaction's author delete it - #85415
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. 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:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +3 B (0%) Total Size: 8.58 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. a navigation superseded by the traversal discharges to idle in
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW
An editor or administrator can currently delete another user's reaction through the generic comment permission check, and reactions on a resolved thread can still be removed. Cover both, plus deleting your own reaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW
Deletion fell through to core's generic check, which lets anyone with moderate_comments or edit_comment remove another user's reaction. Restrict it to the author, and reject deletes on a resolved thread the same way creates already are, sharing the thread-root lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW
The names query used status 'all', while reaction_summary counts approved rows only, so trashed or spammed reactions could push the name list out of step with the count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW
46dc1ff to
acd624a
Compare
|
Pushed a small follow-up:
@adamsilverstein, do we have a core sync PR for this? |
The reaction delete rules are backported in wordpress-develop#15383, not the already-merged #10930. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018vwYjTXU324rGneSjaye87
|
Core backport is up in WordPress/wordpress-develop#15383, and I moved the backport changelog entry to match in 6febc53. |
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.2 branch to get it included in the next release: b49b3d6 |
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
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a - Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848) - Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530) - Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892) - Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565) - Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455) - Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935) - Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060) - Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883) - [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032) - Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050) - [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060) - Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059) - [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062) - Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158) - UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183) - Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959) - Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168) - Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415) - Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408) - Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420) - Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795) - Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777) - Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873) Props mamaduka. See #66340. git-svn-id: https://develop.svn.wordpress.org/trunk@65225 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned commit hash of the Gutenberg repository from `cc75a79186fd23e72eb015d594e82f40c6209eb5` to `c035c1a649ef68f5c1646694cf440df1d7ae6e62` (fixes cherry-picked to the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@cc75a79...c035c1a - Components: Use solid brand highlights for popup items (WordPress/gutenberg#84583) (#85848) - Fix endless sideload loop when the browser can't decode a big image (WordPress/gutenberg#83530) - Notes: Show reaction picker as a row of emoji (WordPress/gutenberg#85819) (#85892) - Notes: Add thumbs up and plus reactions (WordPress/gutenberg#85565) - Notes: Share thread focus recovery across actions (WordPress/gutenberg#85455) - Core Fields: Prevent extra space between `/` and text in slug input (WordPress/gutenberg#85935) - Notes: Add search and a status filter to the All Notes sidebar (WordPress/gutenberg#84060) - Notes: Use the note permission check when deleting a reaction (WordPress/gutenberg#85883) - [WP 7.2] Math block: Keyboard focus is trapped in the LaTeX field when the formula has an error (WordPress/gutenberg#86032) - Core fields: Keep the status icon full size when its label wraps (WordPress/gutenberg#85828) (#86050) - [WP 7.2] ToolsPanel: Keep the "Reset" label visible on the highlighted menu item (WordPress/gutenberg#86060) - Interactivity Router: Ignore router regions and attachTo targets inside data-wp-html content (WordPress/gutenberg#84919) (#86059) - [WP 7.2] wp-build: Derive CSS module class names from each stylesheet's CSS (WordPress/gutenberg#86062) - Playlist: Allow track without an attachment ID to render on the frontend (WordPress/gutenberg#83880) (#86158) - UI: Show only the day number in Calendar day cells (WordPress/gutenberg#86010) (#86183) - Notes: Tolerate a null comment in the reaction cascade hooks (WordPress/gutenberg#85959) - Rich Text: Remove stale format boundary when field loses selection (WordPress/gutenberg#86168) - Notes: Only let a reaction's author delete it (WordPress/gutenberg#85415) - Writing flow: Fix Arrow Up and Down getting stuck at the edge of the screen (WordPress/gutenberg#85408) - Try: Run e2e tests in parallel, on one wp-env site per two cores (WordPress/gutenberg#85420) - Raw handling: Keep shortcodes in text inline (WordPress/gutenberg#85795) - Fix: Fixes non-breaking space replacement tooltip (WordPress/gutenberg#85777) - Non-breaking space: Remove non-breaking spaces that would collapse when replaced (WordPress/gutenberg#85873) Props mamaduka. See #66340. Built from https://develop.svn.wordpress.org/trunk@65225 git-svn-id: http://core.svn.wordpress.org/trunk@64374 1a063a9b-81f0-0310-95a4-ce76da25c4cd


What?
Follow up to #76767. Tightens who can remove a note reaction, and keeps the reaction tooltip's names in step with its count.
Why?
These came up as Copilot findings on #83538 and also apply to trunk now that #76767 has landed:
moderate_commentsoredit_comment) could remove another user's reaction.status: 'all', whilereaction_summaryonly counts approved rows.How?
delete_item_permissions_check()in the 7.2 comments controller: after core's check passes, a reaction can only be deleted by its author, and not while its thread is resolved. Both returnrest_cannot_delete.create_item()into anis_in_resolved_thread()helper so create and delete share it.status: 'approve'for the tooltip names.Testing Instructions
PHPUnit covers the new rules in
phpunit/experimental/class-wp-rest-comments-controller-gutenberg-test.php:test_can_delete_own_reactiontest_cannot_delete_another_users_reaction(administrator and editor)test_cannot_delete_reaction_on_resolved_thread(root note and reply)The tests landed in their own first commit; the Unit Tests run on that commit alone fails them, and they pass with the fix.
Manual check:
wp.apiFetch( { path: '/wp/v2/comments/<reaction id>?force=true', method: 'DELETE' } ). Expect a 403rest_cannot_delete.AI Use
Claude Code wrote the code and this description, with me pointing it at the review findings. I will review and test.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LvpAdxaahosj8kTQtm3NXW