Skip to content

Notes: Use the note permission check when deleting a reaction - #85883

Merged
ramonjd merged 2 commits into
trunkfrom
update/reactions-permissions-check
Oct 29, 2026
Merged

ramonjd merged 2 commits into
trunkfrom
update/reactions-permissions-check

Conversation

@ramonjd

@ramonjd ramonjd commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What?

Deleting a note reaction now needs the same permission as deleting the note: edit access to the note's post.

Why?

The comments controller already treats a reaction like its note when reading or creating one. Deleting was the exception. It went through core's check_edit_permission(), which only knows about notes, so a reaction was checked against the moderate_comments capability instead.

How?

  • Overrides check_edit_permission() in Gutenberg_REST_Comment_Controller_7_2. It's core's method with reaction checked alongside note: both use edit_comment, which maps to edit_post on the note's post. Other comment types still check moderate_comments first.
  • Reactions can't be updated, so this only changes who can delete them.
  • Adds a PHPUnit test with a role that has moderate_comments but can't edit posts.

Testing Instructions

  1. Create a role that can moderate comments but can't edit posts, and a user with that role:
    npm run wp-env -- run cli -- wp role create comment_moderator "Comment Moderator"
    npm run wp-env -- run cli -- wp cap add comment_moderator read moderate_comments
    npm run wp-env -- run cli -- wp user create moderator moderator@example.com --role=comment_moderator
    
  2. As an administrator, open a post, add a note to a block, select the note and use "Add reaction" to react with an emoji.
  3. Find the reaction's ID:
    npm run wp-env -- run cli -- wp comment list --type=reaction --fields=comment_ID,comment_parent,comment_content
    
  4. Try to delete it as the moderator, replacing <id> with the reaction's ID:
    npm run wp-env -- run cli -- wp --user=moderator eval '$request = new WP_REST_Request( "DELETE", "/wp/v2/comments/<id>" ); $request->set_param( "force", true ); echo rest_do_request( $request )->get_status(), "\n";'
    
    With this PR it prints 403 and the command in step 3 still lists the reaction. On trunk it prints 200 and the reaction is gone.
  5. Back in the editor, select the note and click your reaction to remove it. It's removed as before.

A reaction belongs to a note, and the rest of the comments controller
already treats reactions like notes. Deleting one, though, still went
through core's check_edit_permission(), which on WordPress 7.0 and 7.1
only knows about notes, so a reaction was checked against the
moderate_comments capability instead.

Override check_edit_permission() so notes and reactions both use
edit_comment, which maps to edit_post on the note's post. Reactions
cannot be updated, so this only changes who can delete them.

This mirrors a pending WordPress core change. The backport changelog
entry will be added once the core pull request exists.
@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting labels Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: sadmansakibnadvi <sadmansakibnadvi@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 6b234b1 trunk % Change
timeToFirstByte 43.2 ms +5.21% -3.01% 42.7 ms +16.51% -3.28% 1.17%
largestContentfulPaint 76 ms +0% -5.26% 76 ms +5.26% -10.53% 0%
lcpMinusTtfb 29.2 ms +20.38% -5.31% 27.2 ms +12.68% -2.57% 7.35%
wpBeforeTemplate 22.54 ms +6.03% -3.5% 22.31 ms +19.54% -1.93% 1.03%
wpTemplate 17.22 ms +4.18% -4.65% 17.05 ms +10.67% -5.28% 1%
wpTotal 39.92 ms +5.46% -3.88% 39.17 ms +16.44% -2.71% 1.91%
wpMemoryUsage 7.70 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 6b234b1 trunk % Change
timeToFirstByte 31.35 ms +11.96% -1.91% 36 ms +9.03% -3.19% -12.92%
largestContentfulPaint 70 ms +2.86% -2.86% 80 ms +5% -5% -12.5%
lcpMinusTtfb 37.35 ms +3.08% -0.8% 43.05 ms +4.3% -3.83% -13.24%
wpBeforeTemplate 19.08 ms +11.06% -0.63% 19.33 ms +10.5% -1.19% -1.29%
wpTemplate 9.73 ms +9.76% -3.6% 13.6 ms +7.94% -5.66% -28.46%
wpTotal 28.88 ms +12.33% -1.77% 33.12 ms +8.88% -3.17% -12.8%
wpMemoryUsage 6.28 MB +0% -0% 6.36 MB +0% -0% -1.21%
wpDbQueries 9 +0% -0% 13 +0% -0% -30.77%

media-processing

Metric 6b234b1 trunk % Change
mediaProcessingJpeg 325.35 ms +2.07% -0.79% 325.78 ms +1.45% -0.99% -0.13%
mediaProcessingAvif 4853.14 ms +0.5% -0.14% 4857.94 ms +0.5% -0.27% -0.1%
mediaProcessingJpegToAvif 3394.75 ms +0.68% -0.42% 3407.5 ms +0.25% -0.31% -0.37%

media-upload

Metric 6b234b1 trunk % Change
jpegUploadProcessing 1442.01 ms +1.81% -1.57% 1422.33 ms +1.14% -0.48% 1.38%
pngUploadProcessing 231.49 ms +8.22% -6.52% 216.38 ms +7.29% -2.11% 6.98%
largeJpegUploadProcessing 1415.92 ms +0.22% -0.44% 1420.86 ms +0.77% -0.55% -0.35%
multipleImageUploadProcessing 1483.03 ms +1.17% -0.68% 1489.04 ms +2.11% -0.36% -0.4%

post-editor

Metric 6b234b1 trunk % Change
serverResponse 291.84 ms +6% -9.86% 263.34 ms +9.5% -2.92% 10.82%
firstPaint 238.06 ms +38.79% -27.8% 313.78 ms +16.96% -47.07% -24.13%
domContentLoaded 594.57 ms +4.52% -3.71% 587.28 ms +1.81% -1.39% 1.24%
loaded 595.52 ms +4.54% -3.69% 588.11 ms +1.85% -1.25% 1.26%
firstContentfulPaint 363.77 ms +1.45% -9.17% 357.82 ms +2.56% -5.58% 1.66%
firstBlock 1942.15 ms +1.39% -2.76% 1853.67 ms +2.2% -0.87% 4.77%
type 14 ms +8.07% -8% 13.08 ms +8.33% -3.75% 7.03%
typeWithoutInspector 14.53 ms +4.2% -8.05% 12.3 ms +7.07% -7.48% 18.13%
typeWithTopToolbar 17.5 ms +5.66% -7.03% 15.89 ms +5.92% -2.71% 10.13%
typeContainer 6.32 ms +13.77% -7.44% 6.08 ms +12.01% -8.22% 3.95%
focus 81.01 ms +1.59% -8.28% 77.63 ms +2.92% -2.22% 4.35%
firstFocus 177.86 ms +0% -0% 159.29 ms +0% -0% 11.66%
selectAll 317.08 ms +5.06% -3.73% 288.34 ms +4.04% -4.68% 9.97%
undo 22.03 ms +3.9% -4.27% 23.38 ms +5.69% -10.56% -5.77%
listViewOpen 46.85 ms +13.4% -5.87% 47.74 ms +4.63% -8.4% -1.86%
inserterOpen 29.1 ms +9.14% -10.55% 28.83 ms +4.75% -7.91% 0.94%
inserterHover 8.28 ms +8.82% -7.13% 8.81 ms +4.54% -5.33% -6.02%
inserterSearch 6.84 ms +2.63% -5.56% 7.16 ms +3.77% -11.73% -4.47%
loadPatterns 416.86 ms +6.01% -1.07% 458.41 ms +8.36% -6.63% -9.06%
wpTotal 284.62 ms +5.61% -10.12% 255.83 ms +9.87% -2.92% 11.25%
wpMemoryUsage 14.75 MB +0% -0% 14.72 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 6b234b1 trunk % Change
serverResponse 528.8 ms +2.49% -8.53% 523.42 ms +1.94% -4.98% 1.03%
firstPaint 273.36 ms +10.14% -8.28% 280.76 ms +2.46% -10.04% -2.64%
domContentLoaded 906.15 ms +1% -1.27% 894.62 ms +2.72% -0.74% 1.29%
loaded 907.09 ms +1.02% -1.26% 895.63 ms +2.74% -0.75% 1.28%
firstContentfulPaint 510.66 ms +1.35% -2.67% 499.92 ms +2.64% -4.37% 2.15%
firstBlock 3931.9 ms +1.52% -0.83% 3933.02 ms +0.67% -0.77% -0.03%
type 17.23 ms +5.86% -10.97% 18.37 ms +8.27% -3.21% -6.21%
navigate 116.49 ms +10.1% -2.46% 113.62 ms +5.47% -1.21% 2.53%
loadPatterns 1151.65 ms +3.47% -5.07% 1151.32 ms +24.77% -4.63% 0.03%
loadPages 1021.33 ms +2.96% -4.14% 1004.1 ms +2.68% -2.9% 1.72%
wpTotal 518.76 ms +2.65% -8.66% 513.29 ms +2.1% -5.13% 1.07%
wpMemoryUsage 12.77 MB +0% -0% 12.74 MB +0% -0% 0.24%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

540f07c Run

🏁 Flaky tests

Some 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.

As a user I want to be able to add multiple close buttons so that users can close the overlay from different positions in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
Error: expect(locator).toHaveCount(expected) failed

Locator:  getByRole('button', { name: 'Close' })
Expected: 2
Received: 1
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" getByRole('button', { name: 'Close' }) with timeout 5000ms
  - waiting for getByRole('button', { name: 'Close' })
    14 × locator resolved to 1 element
       - unexpected value "1"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:228:33
Custom Completer: should insert option between two other words in /test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js, passed after 2 failed attempts.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/users?per_page=100
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 4ed49b8abd
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1793413433%7CPRiitrfelmLwlOPlDhqnUaj4avjooKn9iH7ewYhmSU6%7C63b6fad9ce381f1a68000b249f9d9aba420652886ee2aa3ae3263b2aa30e5015; wp-settings-time-1=1793241276

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at RequestUtils.listUsers (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:34:30)
    at RequestUtils.deleteAllUsers (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:106:44)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js:73:22

Delete (forward) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  -  5
+ Received  + 11

@@ -1,25 +1,31 @@
  Array [
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "1‸a",
          },
-         "innerBlocks": Array [
+         "innerBlocks": Array [],
+         "name": "core/list-item",
+       },
        Object {
+         "attributes": Object {
+           "content": "2",
+         },
          "innerBlocks": Array [
            Object {
              "attributes": Object {
-                   "content": "a‸2",
+               "ordered": false,
+               "values": "",
              },
-                 "name": "core/list-item",
-               },
+             "innerBlocks": Array [
                Object {
                  "attributes": Object {
                    "content": "b",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
            },

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2056:42
can be copied from multi selection in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 14
+ Received  + 14

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li></li>
- <!-- /wp:list-item -->
-
+ <!-- /wp:list-item --></ul>
- <!-- wp:list-item -->
- <li>two</li>
+ <!-- /wp:list -->
+
- <!-- /wp:list-item --></ul>
+ <!-- wp:paragraph -->
+ <p>two</p>
- <!-- /wp:list -->
+ <!-- /wp:paragraph -->

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li></li>
- <!-- /wp:list-item -->
-
+ <!-- /wp:list-item --></ul>
- <!-- wp:list-item -->
- <li>two</li>
+ <!-- /wp:list -->
+
- <!-- /wp:list-item --></ul>
+ <!-- wp:paragraph -->
+ <p>two</p>
- <!-- /wp:list -->
+ <!-- /wp:paragraph -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:33:49
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should change the indented list type in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:727:3
should cut and paste individual blocks with collapsed selection in /test/e2e/specs/editor/various/copy-cut-paste.spec.js, passed after 1 failed attempt.
Error: expect(string).toMatchSnapshot(expected) failed

  @@ -1,3 +1,3 @@
   <!-- wp:paragraph -->
  -<p>2Cut - collapsed selection</p>
  +<p>2</p>
   <!-- /wp:paragraph -->


    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/copy-cut-paste.spec.js:45:49
should filter mentions by non-latin search terms in /test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js, passed after 2 failed attempts.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → DELETE http://localhost:8889/wp-json/wp/v2/users/30?force=true&reassign=1
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 2d6dcc8b3a
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1793413413%7CjZvmMbwOGASDsBJWOtGg1TXqrClglrq8sANrBhVM26Z%7C0aa755190bf81ea26306d4f70cef3f5fff5a703d116e22cd2a25cd4675fdfb14; wp-settings-time-1=1793241255

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at RequestUtils.deleteUser (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:91:30)
    at map (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:116:51)
    at RequestUtils.deleteAllUsers (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:116:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js:73:3

should format text across blocks in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  Array [
    Object {
      "attributes": Object {
-       "content": "ab",
+       "content": "b",
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2219:41
should gradually multi-select in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
-     "name": "core/column",
+     "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:1194:5
should insert a line break on shift+enter in a non trailing list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 4
+ Received  + 0

@@ -1,11 +1,7 @@
  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a</li>
- <!-- /wp:list-item -->
-
- <!-- wp:list-item -->
  <li>b<br></li>
  <!-- /wp:list-item -->

  <!-- wp:list-item -->
  <li>c</li>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1233:52
should insert a line break on shift+enter in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a<br></li>
+ <li><br></li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1210:52
should offer the formats every selected block allows in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 2
+ Received  + 2

  Object {
-   "anchorOffset": 1,
+   "anchorOffset": 0,
    "blocks": 2,
-   "focusOffset": 1,
+   "focusOffset": 0,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2553:5
should remove an anchored list when deleting its last item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -5,11 +5,11 @@
      },
      "innerBlocks": Array [
        Object {
          "attributes": Object {
            "anchor": "item",
-           "content": "x",
+           "content": "",
          },
          "name": "core/list-item",
        },
      ],
      "name": "core/list",

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2961:41
should replace selected non-breaking spaces from the toolbar in /test/e2e/specs/editor/various/rich-text.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "one two three",
+       "content": "ne two three",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/rich-text.spec.js:1050:41

540f07c Run

@ramonjd ramonjd added the Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core label Oct 29, 2026
@ramonjd ramonjd self-assigned this Oct 29, 2026
@ramonjd
ramonjd marked this pull request as ready for review October 29, 2026 01:53
@ramonjd
ramonjd requested a review from spacedmonkey as a code owner October 29, 2026 01:53
@ramonjd ramonjd added the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 29, 2026
@ramonjd ramonjd removed the Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core label Oct 29, 2026
Comment on lines +368 to +378
protected function check_edit_permission( $comment ) {
if ( 0 === (int) get_current_user_id() ) {
return false;
}

// START CHANGE: Check notes and reactions against the note's post.
/*
* Notes and their reactions are editorial content, so require edit access
* to the note's post rather than the moderate_comments capability.
*/
if ( in_array( strtolower( $comment->comment_type ), array( 'note', 'reaction' ), true ) ) {

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.

Minor - could it use is_note_or_reaction?

Also, that method doesn't strtolower the comment_type. Bug, or is the code here over protective?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah I saw is_note_or_reaction and noticed it was a Gutenberg only helper. Not sure what the reasoning behind that was.

We could use it, but I think matching Core might be less confusing in the end. I'm on the fence. Maybe @adamsilverstein has a preference?

strtolower was there for edge cases to a comment type of Note or Reaction. In the database it's case insensitive.

So where, for example, a comment stored as 'Note' is returned by note queries.

Comment on lines +383 to +387
if ( current_user_can( 'moderate_comments' ) ) {
return true;
}

return current_user_can( 'edit_comment', $comment->comment_ID );

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.

I realise this is the existing code, but maybe it could be:

Suggested change
if ( current_user_can( 'moderate_comments' ) ) {
return true;
}
return current_user_can( 'edit_comment', $comment->comment_ID );
return current_user_can( 'moderate_comments' ) || current_user_can( 'edit_comment', $comment->comment_ID );

@talldan talldan 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.

Does what it says it'll do, so LGTM.

A couple of small code nits.

@Mamaduka

Copy link
Copy Markdown
Member

I think @adamsilverstein is working on something similar (#85415); it's worth double-checking the permissions. User A shouldn't be able to toggle User B's reactions.

@ramonjd

ramonjd commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

I think @adamsilverstein is working on something similar (#85415);

Ah great. Thanks @Mamaduka

Happy to close this and the backport PR - I guess I should have checked, but that would have been too easy. 😄

@Mamaduka

Copy link
Copy Markdown
Member

Let's coordinate this fix; it would be nice to land before the next beta. Thank you, @ramonjd and @talldan!

@adamsilverstein

Copy link
Copy Markdown
Member

#85415 is a bit different than this and is about preventing others from removing your reactions (and removing reactions from resolved threads). We can consider it separately, this PR looks good to me.

@sadmansakibnadvi

Copy link
Copy Markdown

Tested this on WordPress 7.2-beta3-64990 with Gutenberg 24.3.0, applying only the lib/compat/wordpress-7.2/class-gutenberg-rest-comment-controller-7-2.php change and leaving core unpatched, so any change in behavior comes from the Gutenberg controller.

Real REST requests (DELETE /wp/v2/comments/<id>?force=true, cookie auth + nonce), fresh objects for every row. The moderator is a custom role with only read and moderate_comments, same as the core unit test.

User Deleting Gutenberg 24.3.0 With this PR
Comment Moderator editor's reaction 200, deleted 403, kept
Comment Moderator the note (control) 403 403
Comment Moderator regular comment (control) 200 200
Editor admin's reaction 200 200
Editor own reaction 200 200
Contributor editor's reaction 403 403

Matches the core change in WordPress/wordpress-develop#15130, which I tested the same way.

@ramonjd
ramonjd merged commit 64295ee into trunk Oct 29, 2026
97 checks passed
@ramonjd
ramonjd deleted the update/reactions-permissions-check branch October 29, 2026 22:38
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 29, 2026
@github-actions github-actions Bot removed the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 29, 2026
gutenbergplugin pushed a commit that referenced this pull request Oct 29, 2026
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: sadmansakibnadvi <sadmansakibnadvi@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.2 branch to get it included in the next release: 71d0377

wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 3, 2026
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
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 3, 2026
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
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants