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:
Scott Taylor
2014-05-29 20:41:53 +00:00
parent eba9bf7171
commit 8bb2117aad
2 changed files with 26 additions and 3 deletions

View File

@@ -2767,9 +2767,12 @@ class WP_Query {
$r_status = array();
$p_status = array();
$e_status = array();
if ( in_array('any', $q_status) ) {
foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
$e_status[] = "$wpdb->posts.post_status <> '$status'";
if ( in_array( 'any', $q_status ) ) {
foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) {
if ( ! in_array( $status, $q_status ) ) {
$e_status[] = "$wpdb->posts.post_status <> '$status'";
}
}
} else {
foreach ( get_post_stati() as $status ) {
if ( in_array( $status, $q_status ) ) {