From d0bdcc3e7af90fc6fd81c917f9abb492d84233d3 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 29 May 2014 20:42:18 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@28622 git-svn-id: http://core.svn.wordpress.org/trunk@28443 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 2dcc95c949..ddf67d564e 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -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 ) ) {