Make WordPress Core

Changeset 61183


Ignore:
Timestamp:
11/07/2025 06:54:51 PM (3 months ago)
Author:
adamsilverstein
Message:

Comments: ensure notes never show on the comments page.

Fix an issue where adding comment_type=note as a query parameter to the wp-admin/edit-comments.php page would unexpectedly cause notes to show. Notes are different from comments - prevent them from showing on the comment list table.

Props adamsilverstein, desros, soyebsalar01j.
Fixes #64198.

Location:
trunk
Files:
2 edited

Legend:

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

    r61105 r61183  
    100100        }
    101101
    102         $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
     102        $comment_type = '';
     103
     104        if ( ! empty( $_REQUEST['comment_type'] ) && 'note' !== $_REQUEST['comment_type'] ) {
     105            $comment_type = $_REQUEST['comment_type'];
     106        }
    103107
    104108        $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
  • trunk/tests/phpunit/tests/admin/wpCommentsListTable.php

    r58097 r61183  
    214214        $this->assertSame( $expected, $this->table->get_views() );
    215215    }
     216
     217    /**
     218     * Verify that the comments table never shows the note comment_type.
     219     *
     220     * @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(
     225            array(
     226                'comment_post_ID'  => $post_id,
     227                'comment_content'  => 'This is a note.',
     228                'comment_type'     => 'note',
     229                'comment_approved' => '1',
     230            )
     231        );
     232        $comment_id = self::factory()->comment->create(
     233            array(
     234                'comment_post_ID'  => $post_id,
     235                'comment_content'  => 'This is a regular comment.',
     236                'comment_type'     => '',
     237                'comment_approved' => '1',
     238            )
     239        );
     240        // Request the note comment type.
     241        $_REQUEST['comment_type'] = 'note';
     242        $this->table->prepare_items();
     243        $items = $this->table->items;
     244        $this->assertCount( 1, $items );
     245        $this->assertEquals( $comment_id, $items[0]->comment_ID );
     246    }
    216247}
Note: See TracChangeset for help on using the changeset viewer.