mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Comments: Restore the ability to bypass post_id filter using 0 or '0'.
The changes introduced in [36381], while logical and clearly awesome, introduce the potential for much breakage. Those who want to query for comments with a null `comment_post_ID` should use `'post_in' => array( 0 )` instead. Reverts [36381], [36387]. See #35090. git-svn-id: https://develop.svn.wordpress.org/trunk@36480 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -36,12 +36,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
$this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35090
|
||||
*/
|
||||
public function test_post_id_0_should_return_comments_with_no_parent() {
|
||||
public function test_query_post_id_0() {
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) );
|
||||
|
||||
$q = new WP_Comment_Query();
|
||||
$found = $q->query( array(
|
||||
@@ -49,71 +45,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $c2 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35090
|
||||
*/
|
||||
public function test_post_id_string_0_should_return_comments_with_no_parent() {
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) );
|
||||
|
||||
$q = new WP_Comment_Query();
|
||||
$found = $q->query( array(
|
||||
'post_id' => '0',
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $c2 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35090
|
||||
*/
|
||||
public function test_post_id_null_should_be_ignored() {
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) );
|
||||
|
||||
$q = new WP_Comment_Query();
|
||||
$found = $q->query( array(
|
||||
'post_id' => null,
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $c1, $c2 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35090
|
||||
*/
|
||||
public function test_post_id_false_should_be_ignored() {
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) );
|
||||
|
||||
$q = new WP_Comment_Query();
|
||||
$found = $q->query( array(
|
||||
'post_id' => false,
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $c1, $c2 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35090
|
||||
*/
|
||||
public function test_post_id_empty_string_should_be_ignored() {
|
||||
$c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) );
|
||||
$c2 = self::factory()->comment->create( array( 'comment_post_ID' => 0, 'comment_approved' => '1' ) );
|
||||
|
||||
$q = new WP_Comment_Query();
|
||||
$found = $q->query( array(
|
||||
'post_id' => '',
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $c1, $c2 ), $found );
|
||||
$this->assertEqualSets( array( $c1 ), $found );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user