Make WordPress Core

Changeset 61525


Ignore:
Timestamp:
01/26/2026 08:26:37 AM (8 hours ago)
Author:
wildworks
Message:

Comments: Explicitly exclude note comment type on the comments table.

Fix an issue where adding comment_type=all as a query parameter to the wp-admin/edit-comments.php page would unexpectedly cause notes to show.

Follow-up to [61183].

Props adamsilverstein, jorbin, mukesh27, ozgursar, Presskopp, r1k0, rollybueno, soyebsalar01, westonruter, wildworks.
Fixes #64474.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r61521 r61525  
    156156            'post_id'                   => $post_id,
    157157            'type'                      => $comment_type,
     158            'type__not_in'              => array( 'note' ),
    158159            'orderby'                   => $orderby,
    159160            'order'                     => $order,
  • trunk/tests/phpunit/tests/admin/wpCommentsListTable.php

    r61183 r61525  
    219219     *
    220220     * @ticket 64198
    221      */
    222     public function test_comments_list_table_does_not_show_note_comment_type() {
    223         $post_id    = self::factory()->post->create();
    224         $note_id    = self::factory()->comment->create(
     221     * @ticket 64474
     222     *
     223     * @dataProvider data_comment_type
     224     *
     225     * @param string $comment_type The comment_type parameter value to test.
     226     */
     227    public function test_comments_list_table_does_not_show_note_comment_type( string $comment_type ) {
     228        $post_id = self::factory()->post->create();
     229        self::factory()->comment->create(
    225230            array(
    226231                'comment_post_ID'  => $post_id,
     
    228233                'comment_type'     => 'note',
    229234                'comment_approved' => '1',
    230             )
    231         );
    232         $comment_id = self::factory()->comment->create(
     235                'comment_date'     => '2024-01-01 10:00:00',
     236                'comment_date_gmt' => '2024-01-01 10:00:00',
     237            )
     238        );
     239        $regular_comment_id       = self::factory()->comment->create(
    233240            array(
    234241                'comment_post_ID'  => $post_id,
     
    236243                'comment_type'     => '',
    237244                'comment_approved' => '1',
    238             )
    239         );
    240         // Request the note comment type.
    241         $_REQUEST['comment_type'] = 'note';
     245                'comment_date'     => '2024-01-01 11:00:00',
     246                'comment_date_gmt' => '2024-01-01 11:00:00',
     247            )
     248        );
     249        $pingback_comment_id      = self::factory()->comment->create(
     250            array(
     251                'comment_post_ID'  => $post_id,
     252                'comment_content'  => 'This is a pingback comment.',
     253                'comment_type'     => '',
     254                'comment_approved' => '1',
     255                'comment_date'     => '2024-01-01 12:00:00',
     256                'comment_date_gmt' => '2024-01-01 12:00:00',
     257            )
     258        );
     259        $_REQUEST['comment_type'] = $comment_type;
    242260        $this->table->prepare_items();
    243261        $items = $this->table->items;
    244         $this->assertCount( 1, $items );
    245         $this->assertEquals( $comment_id, $items[0]->comment_ID );
     262        $this->assertCount( 2, $items );
     263        $this->assertEquals( $pingback_comment_id, $items[0]->comment_ID );
     264        $this->assertEquals( $regular_comment_id, $items[1]->comment_ID );
     265    }
     266
     267    /**
     268     * Data provider for test_comments_list_table_does_not_show_note_comment_type().
     269     *
     270     * @return array<string, string[]>
     271     */
     272    public function data_comment_type(): array {
     273        return array(
     274            'note type explicitly requested' => array( 'note' ),
     275            'all type requested'             => array( 'all' ),
     276        );
    246277    }
    247278}
Note: See TracChangeset for help on using the changeset viewer.