Ticket #11330: empty-search-string.diff

File empty-search-string.diff, 1.2 KB (added by wonderboymusic, 8 months ago)
Line 
1Index: wp-includes/query.php
2===================================================================
3--- wp-includes/query.php       (revision 21789)
4+++ wp-includes/query.php       (working copy)
5@@ -1480,9 +1480,8 @@
6                } else {
7                // Look for archive queries. Dates, categories, authors, search, post type archives.
8 
9-                       if ( !empty($qv['s']) ) {
10+                       if ( isset( $qv['s'] ) )
11                                $this->is_search = true;
12-                       }
13 
14                        if ( '' !== $qv['second'] ) {
15                                $this->is_time = true;
16@@ -2203,6 +2202,8 @@
17                                if ( !is_user_logged_in() )
18                                        $search .= " AND ($wpdb->posts.post_password = '') ";
19                        }
20+               } elseif ( $this->is_search ) {
21+                       $search = 'AND 0';
22                }
23 
24                // Allow plugins to contextually add/remove/modify the search section of the database query
25@@ -2530,7 +2531,7 @@
26                }
27 
28                // Comments feeds
29-               if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) {
30+               if ( $this->is_comment_feed && ( $this->is_archive || ( $this->is_search && ! empty( $q['s'] ) ) || !$this->is_singular ) ) {
31                        if ( $this->is_archive || $this->is_search ) {
32                                $cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join ";
33                                $cwhere = "WHERE comment_approved = '1' $where";