From 59991fff9bb2c641ec14d56dc5e21b629e3a74e9 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 31 Oct 2025 18:57:30 +0000 Subject: [PATCH] Editor: Notes should not appear in the context of comments. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent notes from inadvertently showing up in the context of comments - including on the Dashboard recent comments widget and the “Mine” count on the Comments page. Notes are stored as a custom ‘note’ comment type and this change ensures the note type is only returned when explicitly requested, or when ‘all’ types are requested. The query for note children is modified to return all child notes. This fixes an issue where children were no longer being returned for the ‘note’ type. Also fixes https://github.com/WordPress/gutenberg/issues/72548. Props adamsilverstein, timothyblynjacobs, shailu25, peterwilsoncc, westonruter, mamaduka, kadamwhite. Fixes #64145. Fixes #64152. Built from https://develop.svn.wordpress.org/trunk@61105 git-svn-id: http://core.svn.wordpress.org/trunk@60441 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-comments-list-table.php | 1 - wp-admin/includes/comment.php | 1 + wp-includes/class-wp-comment-query.php | 10 ++++++++++ wp-includes/comment.php | 1 - .../class-wp-rest-comments-controller.php | 17 +++++++++++++++++ wp-includes/version.php | 2 +- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php index 82cc921ee3..c4d323cf89 100644 --- a/wp-admin/includes/class-wp-comments-list-table.php +++ b/wp-admin/includes/class-wp-comments-list-table.php @@ -151,7 +151,6 @@ class WP_Comments_List_Table extends WP_List_Table { 'order' => $order, 'post_type' => $post_type, 'update_comment_post_cache' => true, - 'type__not_in' => array( 'note' ), ); /** diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index d38ab9447c..ae5ba9d223 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -138,6 +138,7 @@ function get_comment_to_edit( $id ) { * Gets the number of pending comments on a post or posts. * * @since 2.3.0 + * @since 6.9.0 Exclude the 'note' comment type from the count. * * @global wpdb $wpdb WordPress database abstraction object. * diff --git a/wp-includes/class-wp-comment-query.php b/wp-includes/class-wp-comment-query.php index 6c813c7e1a..b2a9275c52 100644 --- a/wp-includes/class-wp-comment-query.php +++ b/wp-includes/class-wp-comment-query.php @@ -536,6 +536,7 @@ class WP_Comment_Query { * Used internally to get a list of comment IDs matching the query vars. * * @since 4.4.0 + * @since 6.9.0 Excludes the 'note' comment type, unless 'all' or the 'note' types are requested. * * @global wpdb $wpdb WordPress database abstraction object. * @@ -770,6 +771,15 @@ class WP_Comment_Query { 'NOT IN' => (array) $this->query_vars['type__not_in'], ); + // 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'; + } + $comment_types = array(); foreach ( $raw_types as $operator => $_raw_types ) { $_raw_types = array_unique( $_raw_types ); diff --git a/wp-includes/comment.php b/wp-includes/comment.php index aa841bfda9..0b07d53d69 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -417,7 +417,6 @@ function get_comment_count( $post_id = 0 ) { 'count' => true, 'update_comment_meta_cache' => false, 'orderby' => 'none', - 'type__not_in' => array( 'note' ), ); if ( $post_id > 0 ) { $args['post_id'] = $post_id; diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index f4f6bdd1f1..4ab82ff7f0 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -1254,6 +1254,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { array( 'count' => true, 'orderby' => 'none', + 'type' => 'all', ) ); @@ -1270,6 +1271,22 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { ); } + // Embedding children for notes requires `type` and `status` inheritance. + if ( isset( $links['children'] ) && 'note' === $comment->comment_type ) { + $args = array( + 'parent' => $comment->comment_ID, + 'type' => $comment->comment_type, + 'status' => 'all', + ); + + $rest_url = add_query_arg( $args, rest_url( $this->namespace . '/' . $this->rest_base ) ); + + $links['children'] = array( + 'href' => $rest_url, + 'embeddable' => true, + ); + } + return $links; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8d0206d17a..06661c8919 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-beta2-61104'; +$wp_version = '6.9-beta2-61105'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.