From 0a1b1b2e88110451ab0e82e65ad0f8a8c05ba04c Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 22 Feb 2007 01:54:28 +0000 Subject: [PATCH] Handle empty search query. Props charleshooper. fixes #3722 #3759 git-svn-id: https://develop.svn.wordpress.org/trunk@4911 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 56ac86f05a..dbb028537e 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -765,9 +765,11 @@ class WP_Query { $searchand = ' AND '; } $term = addslashes_gpc($q['s']); - if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; - - $search = " AND ({$search}) "; + if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) + $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; + + if ( !empty($search) ) + $search = " AND ({$search}) "; } // Category stuff