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)"; }