Make WordPress Core

Changeset 61535


Ignore:
Timestamp:
01/27/2026 02:17:07 AM (6 months 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].

Reviewed by jorbin.
Merges [61525] to the 6.9 branch.

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

Location:
branches/6.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.9

  • branches/6.9/src/wp-admin/includes/class-wp-comments-list-table.php

    r61183 r61535  
    152152                        'post_id'                   => $post_id,
    153153                        'type'                      => $comment_type,
     154                        'type__not_in'              => array( 'note' ),
    154155                        'orderby'                   => $orderby,
    155156                        'order'                     => $order,
  • branches/6.9/tests/phpunit/tests/admin/wpCommentsListTable.php

    r61183 r61535  
    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.