From ba8217c8df22d4ae6cb3a64debc1f6444cbbe6bc Mon Sep 17 00:00:00 2001 From: scribu Date: Sat, 9 Oct 2010 12:18:52 +0000 Subject: [PATCH] Fix warning caused by empty meta query. See #14645 git-svn-id: http://svn.automattic.com/wordpress/trunk@15768 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 8 +++++--- wp-includes/user.php | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index ea236f908c..e6df909eb3 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2113,9 +2113,11 @@ class WP_Query extends WP_Object_Query { $where .= ')'; } - list( $meta_join, $meta_where ) = $this->get_meta_sql( $q['meta_query'], $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' ); - $join .= $meta_join; - $where .= $meta_where; + if ( !empty( $q['meta_query'] ) ) { + list( $meta_join, $meta_where ) = $this->get_meta_sql( $q['meta_query'], $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' ); + $join .= $meta_join; + $where .= $meta_where; + } // Apply filters on where and join prior to paging so that any // manipulations to them are reflected in the paging by day queries. diff --git a/wp-includes/user.php b/wp-includes/user.php index 274baa983b..5e98dd12db 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -461,11 +461,13 @@ class WP_User_Query extends WP_Object_Query { $qv['meta_query'][] = $cap_meta_query; } - list( $meta_join, $meta_where ) = $this->get_meta_sql( $qv['meta_query'], $wpdb->users, 'ID', $wpdb->usermeta, 'user_id' ); - $this->query_from .= $meta_join; - $this->query_where .= $meta_where; + if ( !empty( $qv['meta_query'] ) ) { + list( $meta_join, $meta_where ) = $this->get_meta_sql( $qv['meta_query'], $wpdb->users, 'ID', $wpdb->usermeta, 'user_id' ); + $this->query_from .= $meta_join; + $this->query_where .= $meta_where; + } - if ( !empty($qv['include']) ) { + if ( !empty( $qv['include'] ) ) { $ids = implode( ',', wp_parse_id_list( $qv['include'] ) ); $this->query_where .= " AND $wpdb->users.ID IN ($ids)"; }