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 5f1716199bbe6..59b36ff6da875 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -151,6 +151,7 @@ public function prepare_items() { 'number' => $number, 'post_id' => $post_id, 'type' => $comment_type, + 'type__not_in' => array( 'note' ), 'orderby' => $orderby, 'order' => $order, 'post_type' => $post_type, diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index ed1d3a83bfb38..185bc5bfa48b0 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -218,30 +218,61 @@ public function test_get_views_should_return_views_by_default() { * Verify that the comments table never shows the note comment_type. * * @ticket 64198 + * @ticket 64474 + * + * @dataProvider data_comment_type + * + * @param string $comment_type The comment_type parameter value to test. */ - public function test_comments_list_table_does_not_show_note_comment_type() { - $post_id = self::factory()->post->create(); - $note_id = self::factory()->comment->create( + public function test_comments_list_table_does_not_show_note_comment_type( string $comment_type ) { + $post_id = self::factory()->post->create(); + self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'comment_content' => 'This is a note.', 'comment_type' => 'note', 'comment_approved' => '1', + 'comment_date' => '2024-01-01 10:00:00', + 'comment_date_gmt' => '2024-01-01 10:00:00', ) ); - $comment_id = self::factory()->comment->create( + $regular_comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id, 'comment_content' => 'This is a regular comment.', 'comment_type' => '', 'comment_approved' => '1', + 'comment_date' => '2024-01-01 11:00:00', + 'comment_date_gmt' => '2024-01-01 11:00:00', + ) + ); + $pingback_comment_id = self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_content' => 'This is a pingback comment.', + 'comment_type' => '', + 'comment_approved' => '1', + 'comment_date' => '2024-01-01 12:00:00', + 'comment_date_gmt' => '2024-01-01 12:00:00', ) ); - // Request the note comment type. - $_REQUEST['comment_type'] = 'note'; + $_REQUEST['comment_type'] = $comment_type; $this->table->prepare_items(); $items = $this->table->items; - $this->assertCount( 1, $items ); - $this->assertEquals( $comment_id, $items[0]->comment_ID ); + $this->assertCount( 2, $items ); + $this->assertEquals( $pingback_comment_id, $items[0]->comment_ID ); + $this->assertEquals( $regular_comment_id, $items[1]->comment_ID ); + } + + /** + * Data provider for test_comments_list_table_does_not_show_note_comment_type(). + * + * @return array + */ + public function data_comment_type(): array { + return array( + 'note type explicitly requested' => array( 'note' ), + 'all type requested' => array( 'all' ), + ); } }