Skip to content

Editor: Add emoji reactions as a comment type for Notes - #10930

Open
adamsilverstein wants to merge 40 commits into
WordPress:trunkfrom
adamsilverstein:backport-note-reactions-meta-70
Open

adamsilverstein wants to merge 40 commits into
WordPress:trunkfrom
adamsilverstein:backport-note-reactions-meta-70

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Feb 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a reaction comment type so users can react to collaborative Notes with one of five emoji. Each reaction is stored as its own comment under the note, with comment_type = 'reaction', rather than as serialized meta on the note.

Backport of the PHP changes from WordPress/gutenberg#76767

Changes

  • Storage: a reaction's comment_content is one of five emoji hex keys: 2764, 1f389, 1f604, 1f440, 1f680 (heart, celebration, smile, eyes, rocket). The key is the emoji's lowercase code points padded to four digits, matching the editor's emojiToHexKey(). Raw emoji bytes are not stored, since the comments table isn't guaranteed to be utf8mb4.
  • Avatars: reaction is added to the allowed avatar comment types.
  • Admin, counts and feeds: reactions are kept out of the comments list table and its type filter, the approved and pending comment counts, and comment feeds.
  • REST API, WP_REST_Comments_Controller:
    • Reactions use the note permission checks (edit_post on the note's post rather than moderate_comments), and they're not publicly readable.
    • On create, the parent must be a note on the same post, and that note can't be trashed or spam or anywhere in a resolved thread. The same-post check runs first, so a request can't reveal the status of a note on a post the user can't edit.
    • Content must be one of the five keys. Each user gets one reaction per emoji per note (409 on a duplicate), and reactions are always created approved and pinned to the current user.
    • Reactions can't be edited. Only the user who added a reaction can delete it.
    • Notes get a read-only reaction_summary field, keyed by hex key, with { count, current_user_reaction } for each emoji. Summaries for a page of notes are fetched in two queries.
  • Trash and delete: reactions are trashed with their note and permanently deleted with it. Restoring a note doesn't restore its reactions yet. That's tracked, along with the no-trash case, in Notes: Restore a note's reactions when the note is restored from the trash gutenberg#84202
  • Tests: PHPUnit coverage for all of the above.

Trac ticket

See https://core.trac.wordpress.org/ticket/64638

Test plan

Test in WordPress Playground

  • Create a note on a post via the REST API
  • Add a 2764 (heart) reaction to the note: 201
  • Add the same reaction again: 409
  • Add 1f680 (rocket) to the same note: 201
  • Try heart, 1f44d, or a reaction on a regular comment: 400
  • Resolve the note, then try a reaction on it or on a reply: 400
  • As a second user, try to delete the first user's reaction: 403
  • Check that reactions don't show up in wp-admin Comments, comment counts or comment feeds
  • phpunit --filter WP_Test_REST_Comments_Controller and phpunit --group comment

AI Use

Code and description both written with 🤖 Claude Code, porting the Gutenberg side over. I will review and test.

@github-actions

github-actions Bot commented Feb 14, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein, westonruter, noruzzaman, wildworks.

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

Comment thread src/wp-includes/comment.php Outdated
Comment thread tests/qunit/fixtures/wp-api-generated.js Outdated
Comment thread tests/qunit/fixtures/wp-api-generated.js Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Introduce the `reaction` comment type to support emoji reactions on
collaborative Notes, replacing the previous `_wp_note_reactions` meta
approach.

Changes include:
- Add `reaction` to avatar comment types.
- Exclude reactions from admin comment lists and comment counts.
- Extend the REST API Comments Controller to handle reactions:
  permissions checks, validation (valid emoji slugs, parent must be a
  note, one emoji per user per note), auto-approval, and content
  allowed checks.
- Add PHPUnit tests for reaction creation, validation, and counting.
- Regenerate API fixtures.

Props flavor flavor.
See #63191.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adamsilverstein
adamsilverstein force-pushed the backport-note-reactions-meta-70 branch from e8246a7 to fe19243 Compare February 18, 2026 14:40
@adamsilverstein adamsilverstein changed the title Editor: Register emoji reactions comment meta for Notes Editor: Add emoji reactions as a comment type for Notes Feb 18, 2026
@adamsilverstein

Copy link
Copy Markdown
Member Author

I have updated this backport PR to apply the custom comment type approach for storage used in WordPress/gutenberg#75549 which replaces the meta based approach in WordPress/gutenberg#75144.

Comment thread src/wp-admin/includes/class-wp-comments-list-table.php
Comment thread src/wp-admin/includes/class-wp-comments-list-table.php
Comment thread src/wp-admin/includes/comment.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/link-template.php
Picks up new 'footnotes' meta registered on post types, plus
site_logo and site_icon settings exposed via the REST API.
Needed so 'git diff --exit-code' in the PHPUnit CI step passes
after merging trunk into the backport branch.
…nt_types().

Per review feedback on PR WordPress#10930, introduce wp_get_internal_comment_types()
in src/wp-includes/comment.php as the single source of truth for non-comment
comment types ('note', 'reaction'). The new helper is filterable so future
internal types can be added without touching every call site.

Apply it across the existing 'note'/'reaction' guards:

* WP_Comments_List_Table: comment_type filter and type__not_in.
* get_pending_comments_num(): exclude internal types from pending counts.
* wp_update_comment_count_now(): exclude internal types from approved counts.
* WP_REST_Comments_Controller: get_items / permissions / prepare / links /
  duplicate-flood checks across multiple sites.
* is_avatar_comment_type(): default avatar comment types.

Props westonruter for the suggestion to centralize this list.
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
adamsilverstein added a commit to WordPress/gutenberg that referenced this pull request Apr 29, 2026
…omment_types().

Mirrors the change being proposed for core in
WordPress/wordpress-develop#10930. Introduces a
single helper that returns the list of internal comment types ('note',
'reaction'), filterable so future additions only need to update one place.

Apply it across all the existing 'note'/'reaction' guards in the 7.1
compat layer:

* gutenberg_update_get_avatar_comment_type_7_1() — avatar-eligible types.
* gutenberg_exclude_block_comments_from_admin_7_1() — admin query exclude.
* gutenberg_filter_comment_count_query_exclude_block_comments_7_1() —
  pending-count SQL guard.
* gutenberg_hide_note_from_comment_list_table_7_1() — list table args.
* gutenberg_exclude_notes_from_comment_count_7_1() — approved-count SQL.
* Gutenberg_REST_Comment_Controller_7_1::is_note_or_reaction() — REST
  controller's per-request type check (used by permissions, prepare,
  validation, and links).

Props westonruter for the suggestion to centralize this list.
adamsilverstein and others added 5 commits April 28, 2026 21:30
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Expose the curated reaction emoji list (heart, celebration, smile, eyes,
rocket) via a filterable helper so REST validation and schema can share
a single source. Mirrors gutenberg_get_note_reaction_emojis() from the
Gutenberg notes reactions feature.

See #63191.
Align the reaction comment type handling with the latest Gutenberg
notes reactions PR (WordPress/gutenberg#76767):

- Accept emoji slugs as either a curated slug (heart, celebration,
  smile, eyes, rocket) or a lowercase hex-codepoint sequence (e.g.
  1f44d for 👍 or 1f468-200d-1f4bb for 👨‍💻). Raw emoji bytes are
  rejected since the comments table is not guaranteed to be utf8mb4
  across installs; clients normalize before submitting.
- Scope the uniqueness check to active reactions only, so a user can
  re-add the same emoji after removing (trashing) it on the same note.
- Point note's children link at reaction children, not at notes, so
  embedded children resolve to the reactions on the note.
- Add a read-only reaction_emojis schema property exposing the allowed
  emoji list, so clients can discover accepted slugs via OPTIONS.
- Add a reaction_summary field aggregating per-emoji counts on note
  responses, with reacted/my_reaction_id for the current user.
- Pre-fetch reaction summaries in get_items() to avoid N+1 queries
  when listing many notes.

See #63191.
Add tests covering the updated reaction validation, summary, and
schema behaviors:

- Accept hex-codepoint emoji slugs (e.g. 1f468-200d-1f4bb).
- Reject raw emoji bytes.
- Allow re-adding a reaction after the previous one is trashed.
- reaction_summary aggregates per-emoji counts with the current user's
  reacted state and reaction ID.
- reaction_emojis schema property exposes the curated slug list.
- A note's children link targets reactions, not nested notes.

Update test_get_item_schema for the two new schema properties, and
test_get_note_with_children_link to expect type=reaction for note
children.

See #63191.
- Fix double-space alignment warning in test file (line 4702).
- Extend phpcs:ignore directives in prefetch_reaction_summaries() to
  cover WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber,
  acknowledging PHPCS cannot count placeholders through the spread
  operator.

See #63191.

@t-hamano t-hamano 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.

Thanks for the PR!

My investigation suggests there are still a few places where wp_get_internal_comment_types() should be applied. Below is the code that might be affected.


WP_Comment_Query class:

// Exclude the 'note' comment type, unless 'all' types or the 'note' type explicitly are requested.
if (
! in_array( 'all', $raw_types['IN'], true ) &&
! in_array( 'note', $raw_types['IN'], true ) &&
! in_array( 'note', $raw_types['NOT IN'], true )
) {
$raw_types['NOT IN'][] = 'note';
}


get_lastcommentmodified() function. The SQL query is missing a comment-type filter. This should probably have been fixed in the WordPress 6.9 release.

switch ( $timezone ) {
case 'gmt':
$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
break;
case 'blog':
$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
break;
case 'server':
$add_seconds_server = gmdate( 'Z' );
$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
break;
}

Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/link-template.php Outdated
Apply review feedback from WordPress#10930:

- Bump `@since 7.0.0` to `@since 7.1.0` on PR-introduced docblocks
  in comment.php, link-template.php, and class-wp-rest-comments-controller.php.
- Remove the `wp_internal_comment_types` filter: as an internal helper,
  the list does not need to be filterable.
- Apply `wp_get_internal_comment_types()` in `WP_Comment_Query` so all
  internal types (not just `note`) are excluded by default.
- Exclude internal comment types from the `get_lastcommentmodified()`
  SQL queries so notes and reactions no longer affect the last
  modified date.
- Move `wp_get_note_reaction_emojis()` into
  `WP_REST_Comments_Controller::get_note_reaction_emojis()` as a
  protected static method while the icon strategy is still in flux.
- Simplify the reaction summary prefetch loop in
  `WP_REST_Comments_Controller::get_items()` with `wp_list_pluck`.
@adamsilverstein

adamsilverstein commented May 15, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for the review @t-hamano! I've pushed f3b5af251b addressing the feedback:

  • @since bumps: Updated all PR-introduced @since 7.0.0 to @since 7.1.0 (in comment.php, link-template.php, and class-wp-rest-comments-controller.php).
  • WP_Comment_Query: Updated the existing exclusion block to iterate over wp_get_internal_comment_types() so both note and reaction are excluded by default unless explicitly requested.
  • get_lastcommentmodified(): Added a comment_type NOT IN (…) clause built from wp_get_internal_comment_types() to all three timezone branches so internal comment types no longer affect the last modified date.
  • Reaction icon list: Moved wp_get_note_reaction_emojis() into WP_REST_Comments_Controller::get_note_reaction_emojis() as a protected static method, per your suggestion to avoid a public global while the icon-library plans are still being worked out.
  • wp_internal_comment_types filter: Removed — agreed it's not needed for an internal helper.
  • wp_list_pluck simplification at line 360: Applied. The 'note' === $comment->comment_type check inside the loop was redundant since $request['type'] is already gated to 'note' above and WP_Comment_Query constrains the result set, so it's gone too.

Locally, the relevant test suites (Tests_Comment_*, Tests_REST_Comments, Tests_Avatar) all pass: OK (165 tests, 476 assertions).

scruffian pushed a commit to WordPress/gutenberg that referenced this pull request Jun 30, 2026
…omment_types().

Mirrors the change being proposed for core in
WordPress/wordpress-develop#10930. Introduces a
single helper that returns the list of internal comment types ('note',
'reaction'), filterable so future additions only need to update one place.

Apply it across all the existing 'note'/'reaction' guards in the 7.1
compat layer:

* gutenberg_update_get_avatar_comment_type_7_1() — avatar-eligible types.
* gutenberg_exclude_block_comments_from_admin_7_1() — admin query exclude.
* gutenberg_filter_comment_count_query_exclude_block_comments_7_1() —
  pending-count SQL guard.
* gutenberg_hide_note_from_comment_list_table_7_1() — list table args.
* gutenberg_exclude_notes_from_comment_count_7_1() — approved-count SQL.
* Gutenberg_REST_Comment_Controller_7_1::is_note_or_reaction() — REST
  controller's per-request type check (used by permissions, prepare,
  validation, and links).

Props westonruter for the suggestion to centralize this list.
A reaction stores either a curated slug from get_note_reaction_emojis() or
a lowercase hex codepoint sequence. Acceptance of the latter was dropped
while nothing shipping could decode one back into an emoji and a label, so
a hex slug would have rendered as its raw storage key. The editor's full
emoji picker is that decoder, and it submits this format for every pick
outside the curated list, which the API now has to accept rather than
reject with a 400.

A hex slug is still bounded to assignable Unicode code points: anything
above U+10FFFF or in the UTF-16 surrogate range is rejected, as is a
sequence that is not lowercase.

Props adamsilverstein.
See #63191.
adamsilverstein and others added 6 commits September 29, 2026 11:05
…ons-meta-70

# Conflicts:
#	src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Reactions are stored approved, and the comment feed queries only excluded
notes, so every reaction on a published post showed up in the site and
post comment feeds along with the reacting editor's display name.

The feed WHERE clauses now exclude every type from
wp_get_internal_comment_types(), built in one helper so the two feed
paths cannot drift apart again.

See #63191.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUkvzWUaoyh4ztL1iCcx7M
Removing a reaction trashes it rather than deleting it, and restoring a
note restored every trashed reaction under it. A reaction the user had
taken back came back approved, next to any live one with the same emoji,
breaking the one-emoji-per-user rule and inflating the reaction summary.

Reactions trashed by the note cascade are now flagged, and restoring the
note restores only those. The flag is cleared on any untrash, so it never
outlives the trash round trip.

See #63191.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUkvzWUaoyh4ztL1iCcx7M
The link had been rewritten to filter on `type=reaction` for every note,
so a note with replies advertised a link that never returned them, and
the 6.9 test asserting `type=note` had been changed to match. That breaks
any client that embeds a note's replies.

The link is restored to its trunk form. Reactions are already exposed
through `reaction_summary`, so they are also left out of the check that
decides whether the link appears at all, which keeps a note with only
reactions from advertising an empty children collection.

See #63191.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUkvzWUaoyh4ztL1iCcx7M
The reaction slug was read by passing `content` straight to
wp_strip_all_tags(), so a request using `content: { raw: 'heart' }`,
which prepare_item_for_database() accepts for every other comment,
raised a warning and was rejected as an invalid emoji.

The slug is now read from `content` or `content.raw` the same way
prepare_item_for_database() reads it, and trimmed to match what gets
stored.

See #63191.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUkvzWUaoyh4ztL1iCcx7M
Anyone who could edit the post could send `status: 'hold'` (or spam, or
trash) with a new reaction. The uniqueness check, the race cleanup and
the reaction summary only look at approved rows, so repeated requests
stacked up hidden duplicates for one user that the API could not later
fix, since reactions cannot be updated. Because the status was applied
after the race cleanup, it could also land on a row that another
request had created.

A reaction request with any status other than approved is now rejected,
and reactions skip the post-insert status handling entirely.

See #63191.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UUkvzWUaoyh4ztL1iCcx7M
Replace the `reacted` boolean and `my_reaction_id` with a single
`current_user_reaction` field holding the current user's reaction
comment ID, or 0 when they have not reacted. The boolean was derivable
from the ID, so one field keeps the response smaller and unambiguous,
per review feedback on the Gutenberg companion PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012dpDEqJD9APinkNrMN7Kem
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/comment.php Outdated
*
* @return string[] List of internal comment type slugs.
*/
function wp_get_internal_comment_types(): array {

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.

Personally, I am not sure if we should define what counts as an internal comment type here right now. For example, reactions should be flexible enough to also be used as reactions to public comments in the future.

How about considering a function like this later, when implementing a custom comment types API becomes a realistic option? For now, I think it would be better to drop wp_get_internal_comment_types() and simply define 'reaction'.

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.

good point, I'll just make this a private helper function (could just be _ prefixed) for now since we still need to know which types are internal in multiple places.

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.

Thanks @t-hamano, good point about not locking in an "internal comment type" concept before a custom comment types API exists. I went with a middle ground in c15e3ff.

Claude helped me land on this one:

The helper is now _wp_get_internal_comment_types(), marked @access private with a note that it may change or be replaced once a custom comment types API lands. The get_avatar_comment_types filter docs no longer reference it and just list the defaults.

Keeping it as a helper rather than inlining 'reaction' avoids repeating array( 'note', 'reaction' ) at roughly a dozen call sites (list table, comment counts, WP_Comment_Query, feeds, REST permissions). A private function can be reworked freely later, including when reactions on public comments come up, without any back compat burden.

Does that work for you, or would you still prefer the literals inline?

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.

It seems that functions marked as private have sometimes been removed without prior notice in the past, while in other cases they were kept as deprecated. The backward compatibility policy applied appears to be inconsistent. Personally, I would prefer to inline everything for now, but I would like to hear others' opinions as well.

@adamsilverstein adamsilverstein Oct 7, 2026 •

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.

I would be fine just inlining this for now... except we call the function many times in this PR so thsat would add quite a bit of duplicated code. I've tried to make the method as private as possible now.

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.

I think it would be better to drop wp_get_internal_comment_types() and simply define 'reaction'.

I'm not sure I understand this suggest, can you elaborate?

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.

Sorry, I simply meant hardcoding reaction in all places, as shown below.

Details
diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php
index b4996b0d10..1dff5d2675 100644
--- a/src/wp-admin/includes/class-wp-comments-list-table.php
+++ b/src/wp-admin/includes/class-wp-comments-list-table.php
@@ -107,7 +107,7 @@ class WP_Comments_List_Table extends WP_List_Table {
 
 		$comment_type = '';
 
-		if ( ! empty( $_REQUEST['comment_type'] ) && ! in_array( $_REQUEST['comment_type'], _wp_get_internal_comment_types(), true ) ) {
+		if ( ! empty( $_REQUEST['comment_type'] ) && ! in_array( $_REQUEST['comment_type'], array( 'note', 'reaction' ), true ) ) {
 			$comment_type = $_REQUEST['comment_type'];
 		}
 
@@ -157,7 +157,7 @@ class WP_Comments_List_Table extends WP_List_Table {
 			'number'                    => $number,
 			'post_id'                   => $post_id,
 			'type'                      => $comment_type,
-			'type__not_in'              => _wp_get_internal_comment_types(),
+			'type__not_in'              => array( 'note', 'reaction' ),
 			'orderby'                   => $orderby,
 			'order'                     => $order,
 			'post_type'                 => $post_type,
diff --git a/src/wp-admin/includes/comment.php b/src/wp-admin/includes/comment.php
index cdb8af1efa..1cfc93144e 100644
--- a/src/wp-admin/includes/comment.php
+++ b/src/wp-admin/includes/comment.php
@@ -223,7 +223,7 @@ function get_comment_to_edit( $id ) {
  *
  * @since 2.3.0
  * @since 6.9.0 Exclude the 'note' comment type from the count.
- * @since 7.2.0 Exclude every internal comment type from the count.
+ * @since 7.2.0 Exclude the 'reaction' comment type from the count.
  *
  * @global wpdb $wpdb WordPress database abstraction object.
  *
@@ -243,16 +243,7 @@ function get_pending_comments_num( $post_id ) {
 	$post_id_array = array_map( 'intval', $post_id_array );
 	$post_id_in    = "'" . implode( "', '", $post_id_array ) . "'";
 
-	$internal_comment_types = _wp_get_internal_comment_types();
-	$type_placeholders      = implode( ', ', array_fill( 0, count( $internal_comment_types ), '%s' ) );
-	$pending                = $wpdb->get_results(
-		$wpdb->prepare(
-			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-			"SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' AND comment_type NOT IN ( $type_placeholders ) GROUP BY comment_post_ID",
-			$internal_comment_types
-		),
-		ARRAY_A
-	);
+	$pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' AND comment_type NOT IN ( 'note', 'reaction' ) GROUP BY comment_post_ID", ARRAY_A );
 
 	if ( $single ) {
 		if ( empty( $pending ) ) {
diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
index 095d055c68..76367e43ee 100644
--- a/src/wp-includes/class-wp-comment-query.php
+++ b/src/wp-includes/class-wp-comment-query.php
@@ -549,7 +549,7 @@ class WP_Comment_Query {
 	 *
 	 * @since 4.4.0
 	 * @since 6.9.0 Excludes the 'note' comment type, unless 'all' or the 'note' types are requested.
-	 * @since 7.2.0 Excludes every internal comment type, unless 'all' or that type is requested.
+	 * @since 7.2.0 Excludes the 'reaction' comment type, unless 'all' or the 'reaction' types are requested.
 	 *
 	 * @global wpdb $wpdb WordPress database abstraction object.
 	 *
@@ -785,14 +785,14 @@ class WP_Comment_Query {
 			'NOT IN' => (array) $this->query_vars['type__not_in'],
 		);
 
-		// Exclude internal comment types, unless 'all' types or a specific internal type is explicitly requested.
+		// Exclude the 'note' and 'reaction' comment types, unless 'all' types or that type explicitly are requested.
 		if ( ! in_array( 'all', $raw_types['IN'], true ) ) {
-			foreach ( _wp_get_internal_comment_types() as $internal_type ) {
+			foreach ( array( 'note', 'reaction' ) as $excluded_type ) {
 				if (
-					! in_array( $internal_type, $raw_types['IN'], true ) &&
-					! in_array( $internal_type, $raw_types['NOT IN'], true )
+					! in_array( $excluded_type, $raw_types['IN'], true ) &&
+					! in_array( $excluded_type, $raw_types['NOT IN'], true )
 				) {
-					$raw_types['NOT IN'][] = $internal_type;
+					$raw_types['NOT IN'][] = $excluded_type;
 				}
 			}
 		}
diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php
index 60dfd1fea9..4f98934468 100644
--- a/src/wp-includes/class-wp-query.php
+++ b/src/wp-includes/class-wp-query.php
@@ -2801,15 +2801,13 @@ class WP_Query {
 
 		// Comments feeds.
 		if ( $this->is_comment_feed && ! $this->is_singular ) {
-			$internal_types_where = $this->get_comment_feed_internal_types_where();
-
 			if ( $this->is_archive || $this->is_search ) {
 				$cjoin    = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID ) $join ";
-				$cwhere   = "WHERE comment_approved = '1' AND $internal_types_where $where";
+				$cwhere   = "WHERE comment_approved = '1' AND {$wpdb->comments}.comment_type NOT IN ( 'note', 'reaction' ) $where";
 				$cgroupby = "{$wpdb->comments}.comment_id";
 			} else { // Other non-singular, e.g. front.
 				$cjoin    = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID )";
-				$cwhere   = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1' AND $internal_types_where";
+				$cwhere   = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1' AND {$wpdb->comments}.comment_type NOT IN ( 'note', 'reaction' )";
 				$cgroupby = '';
 			}
 
@@ -3526,7 +3524,7 @@ class WP_Query {
 			$cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
 
 			/** This filter is documented in wp-includes/class-wp-query.php */
-			$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1' AND " . $this->get_comment_feed_internal_types_where(), &$this ) );
+			$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1' AND {$wpdb->comments}.comment_type NOT IN ( 'note', 'reaction' )", &$this ) );
 
 			/** This filter is documented in wp-includes/class-wp-query.php */
 			$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
@@ -3657,28 +3655,6 @@ class WP_Query {
 		return $this->posts;
 	}
 
-	/**
-	 * Builds the SQL condition that keeps internal comment types out of comment feeds.
-	 *
-	 * Notes and reactions are stored approved, so without this condition they
-	 * would be published in the site and post comment feeds.
-	 *
-	 * @since 7.2.0
-	 *
-	 * @global wpdb $wpdb WordPress database abstraction object.
-	 *
-	 * @return string SQL condition, without a leading `AND`.
-	 */
-	private function get_comment_feed_internal_types_where() {
-		global $wpdb;
-
-		$internal_types = _wp_get_internal_comment_types();
-		$placeholders   = implode( ', ', array_fill( 0, count( $internal_types ), '%s' ) );
-
-		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
-		return $wpdb->prepare( "{$wpdb->comments}.comment_type NOT IN ( $placeholders )", $internal_types );
-	}
-
 	/**
 	 * Sets up the amount of found posts and the number of pages (if limit clause was used)
 	 * for the current query.
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 11f5e5fab6..f290c3b27d 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -351,26 +351,6 @@ function get_comment_statuses() {
 	return $status;
 }
 
-/**
- * Retrieves the list of internal comment types.
- *
- * Internal comment types are used by core features (such as block notes
- * and emoji reactions) and are not user-authored discussion comments.
- * They should typically be excluded from front-end and admin comment
- * listings, counts, and similar contexts that target user discussion.
- *
- * This is a private helper and not a public API. It may change or be
- * replaced once a custom comment types API exists.
- *
- * @since 7.2.0
- * @access private
- *
- * @return string[] List of internal comment type slugs.
- */
-function _wp_get_internal_comment_types(): array {
-	return array( 'note', 'reaction' );
-}
-
 /**
  * Retrieves the IDs of a note's reaction comments.
  *
@@ -455,7 +435,7 @@ function get_default_comment_status( $post_type = 'post', $comment_type = 'comme
  * @since 1.5.0
  * @since 4.7.0 Replaced caching the modified date in a local static variable
  *              with the Object Cache API.
- * @since 7.2.0 Internal comment types are excluded from the query.
+ * @since 7.2.0 The 'note' and 'reaction' comment types are excluded from the query.
  *
  * @global wpdb $wpdb WordPress database abstraction object.
  *
@@ -473,30 +453,17 @@ function get_lastcommentmodified( $timezone = 'server' ) {
 		return $comment_modified_date;
 	}
 
-	// Exclude internal comment types (notes, reactions, etc.) from the lookup.
-	$internal_types = _wp_get_internal_comment_types();
-	if ( ! empty( $internal_types ) ) {
-		$placeholders = implode( ', ', array_fill( 0, count( $internal_types ), '%s' ) );
-		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
-		$type_not_in = $wpdb->prepare( " AND comment_type NOT IN ( $placeholders )", $internal_types );
-	} else {
-		$type_not_in = '';
-	}
-
 	switch ( $timezone ) {
 		case 'gmt':
-			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-			$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1'{$type_not_in} ORDER BY comment_date_gmt DESC LIMIT 1" );
+			$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type NOT IN ( 'note', 'reaction' ) ORDER BY comment_date_gmt DESC LIMIT 1" );
 			break;
 		case 'blog':
-			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-			$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1'{$type_not_in} ORDER BY comment_date_gmt DESC LIMIT 1" );
+			$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type NOT IN ( 'note', 'reaction' ) ORDER BY comment_date_gmt DESC LIMIT 1" );
 			break;
 		case 'server':
 			$add_seconds_server = gmdate( 'Z' );
 
-			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-			$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1'{$type_not_in} ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
+			$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type NOT IN ( 'note', 'reaction' ) ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
 			break;
 	}
 
@@ -3253,14 +3220,7 @@ function wp_update_comment_count_now( $post_id ) {
 	$new = apply_filters( 'pre_wp_update_comment_count_now', null, $old, $post_id );
 
 	if ( is_null( $new ) ) {
-		$internal_comment_types = _wp_get_internal_comment_types();
-		$type_placeholders      = implode( ', ', array_fill( 0, count( $internal_comment_types ), '%s' ) );
-		$new                    = (int) $wpdb->get_var(
-			$wpdb->prepare(
-				"SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND comment_type NOT IN ( $type_placeholders )", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
-				array_merge( array( $post_id ), $internal_comment_types )
-			)
-		);
+		$new = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND comment_type NOT IN ( 'note', 'reaction' )", $post_id ) );
 	} else {
 		$new = (int) $new;
 	}
diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
index 65adb2514b..f6bd62e0e3 100644
--- a/src/wp-includes/link-template.php
+++ b/src/wp-includes/link-template.php
@@ -4383,7 +4383,7 @@ function is_avatar_comment_type( $comment_type ) {
 	 * @param array $types An array of content types. Default contains 'comment', 'note',
 	 *                     and 'reaction'.
 	 */
-	$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array_merge( array( 'comment' ), _wp_get_internal_comment_types() ) );
+	$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment', 'note', 'reaction' ) );
 
 	return in_array( $comment_type, (array) $allowed_comment_types, true );
 }
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
index 1a5c814ef2..bc3dbb25e3 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
@@ -151,7 +151,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 	 * @return true|WP_Error True if the request has read access, error object otherwise.
 	 */
 	public function get_items_permissions_check( $request ) {
-		$is_note          = in_array( $request['type'], _wp_get_internal_comment_types(), true );
+		$is_note          = in_array( $request['type'], array( 'note', 'reaction' ), true );
 		$is_edit_context  = 'edit' === $request['context'];
 		$protected_params = array( 'author', 'author_exclude', 'author_email', 'type', 'status' );
 		$forbidden_params = array();
@@ -485,7 +485,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 		}
 
 		// Re-map edit context capabilities when requesting `note` or `reaction` type.
-		$edit_cap = in_array( $comment->comment_type, _wp_get_internal_comment_types(), true ) ? array( 'edit_comment', $comment->comment_ID ) : array( 'moderate_comments' );
+		$edit_cap = in_array( $comment->comment_type, array( 'note', 'reaction' ), true ) ? array( 'edit_comment', $comment->comment_ID ) : array( 'moderate_comments' );
 		if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( ...$edit_cap ) ) {
 			return new WP_Error(
 				'rest_forbidden_context',
@@ -544,7 +544,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 	 * @return true|WP_Error True if the request has access to create items, error object otherwise.
 	 */
 	public function create_item_permissions_check( $request ) {
-		$is_note = ! empty( $request['type'] ) && in_array( $request['type'], _wp_get_internal_comment_types(), true );
+		$is_note = ! empty( $request['type'] ) && in_array( $request['type'], array( 'note', 'reaction' ), true );
 
 		if ( ! is_user_logged_in() && $is_note ) {
 			return new WP_Error(
@@ -724,7 +724,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 		}
 
 		// Do not allow comments to be created with a non-core type.
-		if ( ! empty( $request['type'] ) && ! in_array( $request['type'], array_merge( array( 'comment' ), _wp_get_internal_comment_types() ), true ) ) {
+		if ( ! empty( $request['type'] ) && ! in_array( $request['type'], array( 'comment', 'note', 'reaction' ), true ) ) {
 			return new WP_Error(
 				'rest_invalid_comment_type',
 				__( 'Cannot create a comment with that type.' ),
@@ -983,7 +983,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 
 		// Don't check for duplicates or flooding for notes or reactions.
 		$prepared_comment['comment_approved'] =
-			in_array( $prepared_comment['comment_type'], _wp_get_internal_comment_types(), true ) ?
+			in_array( $prepared_comment['comment_type'], array( 'note', 'reaction' ), true ) ?
 			'1' :
 			wp_allow_comment( $prepared_comment, true );
 
@@ -2381,7 +2381,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 	 * @return bool Whether the comment can be read.
 	 */
 	protected function check_read_permission( $comment, $request ) {
-		if ( ! in_array( $comment->comment_type, _wp_get_internal_comment_types(), true ) && ! empty( $comment->comment_post_ID ) ) {
+		if ( ! in_array( $comment->comment_type, array( 'note', 'reaction' ), true ) && ! empty( $comment->comment_post_ID ) ) {
 			$post = get_post( $comment->comment_post_ID );
 			if ( $post ) {
 				if ( $this->check_read_post_permission( $post, $request ) && 1 === (int) $comment->comment_approved ) {

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.

Ok, got it - will do.

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.

Claude made the change as suggested:

Thanks for the clarification. _wp_get_internal_comment_types() and the WP_Query feed helper are gone, and note/reaction are now hardcoded everywhere, as in your diff (tests updated to match). Pushed in ff65798.

adamsilverstein and others added 2 commits October 7, 2026 10:26
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Avoid committing to a public "internal comment type" concept before a
custom comment types API exists. The list now lives in a private helper
that can change freely, while keeping the note and reaction exclusions
in one place instead of repeating the literals at every call site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019bw9jxkJwGzejoE6KbwXg2
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
adamsilverstein and others added 2 commits October 7, 2026 22:35
Co-authored-by: Weston Ruter <westonruter@gmail.com>
…ons-meta-70

# Conflicts:
#	src/wp-includes/class-wp-query.php
adamsilverstein and others added 6 commits October 7, 2026 23:50
Store a reaction as the hex key of one of the five curated emoji (heart,
celebration, smile, eyes, rocket), the lowercase code points padded to four
digits that the editor's `emojiToHexKey()` produces. This matches the
Gutenberg implementation, so the client and server agree on a single
storage format.

The curated slugs and arbitrary hex sequences are no longer accepted, and
the `reaction_emojis` schema property is removed along with the list that
backed it, since the editor does not read it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a8BrMHjzF5oUjpCyXWoRu
Only the user who added a reaction can delete it. Anyone who can edit the
post can edit a note, and the generic delete check follows that, but a
reaction belongs to its author.

Reject a reaction whose parent note is trashed or spammed, since it would
escape the trash cascade, and one anywhere in a resolved thread, since the
editor disables reactions once a thread's root note is approved. The walk
up to the thread root guards against a cyclic parent chain.

These match the checks in the Gutenberg implementation. Test notes that
receive reactions are now created open, as the editor creates them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a8BrMHjzF5oUjpCyXWoRu
wp_untrash_comment() restores no children of any type, including a note's
replies, so bringing back only reactions was inconsistent and needed a
`_wp_trash_meta_with_note` marker to tell them apart from reactions the
user had removed. Leave restoring children to a cascade that covers every
child type together, matching the Gutenberg implementation.

Reactions are still trashed with their note and permanently deleted with
it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a8BrMHjzF5oUjpCyXWoRu
The trashed, spam and resolved checks ran before the check that the parent
note belongs to the reaction's post. A user who can edit one post could
pass the ID of a note on a post they cannot edit and tell from the error
whether that note is trashed, spammed or resolved. Run the same-post check
first, so a note on another post always gets the same error.

`post` is already required for every comment type by
create_item_permissions_check(), which also checks edit access to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a8BrMHjzF5oUjpCyXWoRu
Mirror two Gutenberg tests: a reaction is readable only by its author and
users who can edit it, and a later page of notes still builds its reaction
summaries with two queries rather than one per note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a8BrMHjzF5oUjpCyXWoRu
adamsilverstein and others added 3 commits October 9, 2026 10:55
Drop _wp_get_internal_comment_types() and hardcode 'note' and 'reaction'
where they are excluded or checked. Deciding what counts as an internal
comment type is better left to a future custom comment types API, since
reactions may later apply to public comments too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GEVg3cSmkAtseftqMbo4Zz
The previous commit regenerated wp-api-generated.js against a local site
with a different tagline, so CI's regenerated fixture no longer matched
and the "version-controlled files are not modified" check failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019bw9jxkJwGzejoE6KbwXg2
The tests referenced #63191, an unrelated ticket. See #64638.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FGp5zYv14MKoTuh3RFuWi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Sync Pull requests syncing changes from WordPress/Gutenberg.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants