mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
If post_status is passed to WP_Query as an array containing 'any' and anything else, don't exclude the other values if they match when running any's exclusion logic.
Adds unit tests. Fixes #28007. git-svn-id: https://develop.svn.wordpress.org/trunk@28622 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -741,4 +741,24 @@ class Tests_Post_Query extends WP_UnitTestCase {
|
||||
) );
|
||||
$this->assertEqualSets( $ordered, wp_list_pluck( $attached->posts, 'ID' ) );
|
||||
}
|
||||
|
||||
function test_post_status() {
|
||||
$statuses1 = get_post_stati();
|
||||
$this->assertContains( 'auto-draft', $statuses1 );
|
||||
|
||||
$statuses2 = get_post_stati( array( 'exclude_from_search' => true ) );
|
||||
$this->assertContains( 'auto-draft', $statuses2 );
|
||||
|
||||
$statuses3 = get_post_stati( array( 'exclude_from_search' => false ) );
|
||||
$this->assertNotContains( 'auto-draft', $statuses3 );
|
||||
|
||||
$q1 = new WP_Query( array( 'post_status' => 'any' ) );
|
||||
$this->assertContains( "post_status <> 'auto-draft'", $q1->request );
|
||||
|
||||
$q2 = new WP_Query( array( 'post_status' => 'any, auto-draft' ) );
|
||||
$this->assertNotContains( "post_status <> 'auto-draft'", $q2->request );
|
||||
|
||||
$q3 = new WP_Query( array( 'post_status' => array( 'any', 'auto-draft' ) ) );
|
||||
$this->assertNotContains( "post_status <> 'auto-draft'", $q3->request );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user