From d6baca3c35f32384e1074f8ff94bd1882d1d0540 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 2 Feb 2014 07:36:13 +0000 Subject: [PATCH] Fix an error in SQL generation when `perm` is set and an array is passed for `post_status`. Adds unit test. Props oso96_2000. Fixes #25523. Built from https://develop.svn.wordpress.org/trunk@27067 git-svn-id: http://core.svn.wordpress.org/trunk@26940 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 417405d677..3276351f31 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2756,8 +2756,10 @@ class WP_Query { foreach ( $statuswheres as $index => $statuswhere ) $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; } - foreach ( $statuswheres as $statuswhere ) - $where .= " AND $statuswhere"; + $where_status = implode( ' OR ', $statuswheres ); + if ( ! empty( $where_status ) ) { + $where .= " AND ($where_status)"; + } } elseif ( !$this->is_singular ) { $where .= " AND ($wpdb->posts.post_status = 'publish'";