From 4a2c4c8f0176605f960da23bf4ca4cc22bdb0cd2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 4 Sep 2013 18:51:10 +0000 Subject: [PATCH] Kill the query in the following edge case: `post_type => 'any'` but `exclude_from_search => false` returns no valid post types. Adds unit tests. Props mitchoyoshitaka. Fixes #19198. Built from https://develop.svn.wordpress.org/trunk@25239 git-svn-id: http://core.svn.wordpress.org/trunk@25209 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index af558fe06e..7dfaae037e 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2455,7 +2455,9 @@ class WP_Query { if ( 'any' == $post_type ) { $in_search_post_types = get_post_types( array('exclude_from_search' => false) ); - if ( ! empty( $in_search_post_types ) ) + if ( empty( $in_search_post_types ) ) + $where .= ' AND 1=0 '; + else $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')"; } elseif ( !empty( $post_type ) && is_array( $post_type ) ) { $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')";