Skip to content

Commit d1a7c29

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@61183 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f8f4212 commit d1a7c29

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ public function prepare_items() {
9999
$comment_status = 'all';
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'] : '';
105109

tests/phpunit/tests/admin/wpCommentsListTable.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,35 @@ public function test_get_views_should_return_views_by_default() {
213213
);
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
}

0 commit comments

Comments
 (0)