Fix warning caused by empty meta query. See #14645

git-svn-id: http://svn.automattic.com/wordpress/trunk@15768 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-10-09 12:18:52 +00:00
parent 7bb63ebe44
commit ba8217c8df
2 changed files with 11 additions and 7 deletions

View File

@ -2113,9 +2113,11 @@ class WP_Query extends WP_Object_Query {
$where .= ')'; $where .= ')';
} }
list( $meta_join, $meta_where ) = $this->get_meta_sql( $q['meta_query'], $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' ); if ( !empty( $q['meta_query'] ) ) {
$join .= $meta_join; list( $meta_join, $meta_where ) = $this->get_meta_sql( $q['meta_query'], $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' );
$where .= $meta_where; $join .= $meta_join;
$where .= $meta_where;
}
// Apply filters on where and join prior to paging so that any // Apply filters on where and join prior to paging so that any
// manipulations to them are reflected in the paging by day queries. // manipulations to them are reflected in the paging by day queries.

View File

@ -461,11 +461,13 @@ class WP_User_Query extends WP_Object_Query {
$qv['meta_query'][] = $cap_meta_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' ); if ( !empty( $qv['meta_query'] ) ) {
$this->query_from .= $meta_join; list( $meta_join, $meta_where ) = $this->get_meta_sql( $qv['meta_query'], $wpdb->users, 'ID', $wpdb->usermeta, 'user_id' );
$this->query_where .= $meta_where; $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'] ) ); $ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
$this->query_where .= " AND $wpdb->users.ID IN ($ids)"; $this->query_where .= " AND $wpdb->users.ID IN ($ids)";
} }