diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
index e30094d..9c8c80b 100644
|
a
|
b
|
class WP_Comment_Query {
|
| 634 | 634 | $post_id = absint( $this->query_vars['post_id'] ); |
| 635 | 635 | if ( ! empty( $post_id ) ) { |
| 636 | 636 | $this->sql_clauses['where']['post_id'] = $wpdb->prepare( 'comment_post_ID = %d', $post_id ); |
| | 637 | } else { |
| | 638 | $this->sql_clauses['where']['post_id'] = 'comment_post_ID IN ( 0, "")'; |
| 637 | 639 | } |
| 638 | 640 | |
| 639 | 641 | // Parse comment IDs for an IN clause. |
diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php
index 5d250ea..4bd6f7c 100644
|
a
|
b
|
class Tests_Comment_Query extends WP_UnitTestCase {
|
| 39 | 39 | 'fields' => 'ids', |
| 40 | 40 | ) ); |
| 41 | 41 | |
| 42 | | $this->assertEqualSets( array( $c1 ), $found ); |
| | 42 | $this->assertEmpty( $found ); |
| | 43 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) ); |
| | 44 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => '', 'comment_approved' => '1' ) ); |
| | 45 | |
| | 46 | $q = new WP_Comment_Query(); |
| | 47 | $found = $q->query( array( |
| | 48 | 'post_id' => 0, |
| | 49 | 'fields' => 'ids', |
| | 50 | ) ); |
| | 51 | $this->assertEqualSets( array( $c2, $c3 ), $found ); |
| 43 | 52 | } |
| 44 | 53 | |
| 45 | 54 | /** |