mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Respect all post-related filters in WP_Comment_Query.
The refactor of `WP_Comment_Query`'s SQL generation in [34542] introduced a bug that caused only the last post-related filter to be respected in comment queries. In other words, if querying for comments using params `post_status=draft&post_author=3`, only the last-processed of these params would be respected. The current changeset fixes the logic so that these clauses don't overwrite each other. Props chriscct7. Fixes #35478. git-svn-id: https://develop.svn.wordpress.org/trunk@36326 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -534,6 +534,43 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
$this->assertEqualSets( array( $c1, $c2 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35478
|
||||
*/
|
||||
public function test_multiple_post_fields_should_all_be_respected() {
|
||||
$posts = array();
|
||||
|
||||
$posts[] = self::factory()->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_author' => 3,
|
||||
) );
|
||||
|
||||
$posts[] = self::factory()->post->create( array(
|
||||
'post_status' => 'draft',
|
||||
'post_author' => 4,
|
||||
) );
|
||||
|
||||
$posts[] = self::factory()->post->create( array(
|
||||
'post_status' => 'draft',
|
||||
'post_author' => 3,
|
||||
) );
|
||||
|
||||
$comments = array();
|
||||
foreach ( $posts as $post ) {
|
||||
$comments[] = self::factory()->comment->create( array(
|
||||
'comment_post_ID' => $post,
|
||||
) );
|
||||
}
|
||||
|
||||
$q = new WP_Comment_Query( array(
|
||||
'post_status' => 'draft',
|
||||
'post_author' => 3,
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertSame( array( $comments[2] ), $q->comments );
|
||||
}
|
||||
|
||||
function test_get_comments_for_post() {
|
||||
$limit = 5;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user