mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Return an empty array from get_approved_comments() when $post_id is empty.
This behavior was broken when moving the internals to `WP_Comment_Query` in [30098]. As a result, `get_approved_comments( 0 )` was fetching *all* approved comments, causing performance issues. Props dd32. Fixes #30412. git-svn-id: https://develop.svn.wordpress.org/trunk@30402 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -30,4 +30,16 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
// all comments types will be returned
|
||||
$this->assertEquals( array( $ca1, $ca2, $c2, $c3, $c4, $c5 ), wp_list_pluck( $found, 'comment_ID' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30412
|
||||
*/
|
||||
public function test_get_approved_comments_with_post_id_0_should_return_empty_array() {
|
||||
$p = $this->factory->post->create();
|
||||
$ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );
|
||||
|
||||
$found = get_approved_comments( 0 );
|
||||
|
||||
$this->assertSame( array(), $found );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user