Use group by for meta key queries. Props filosofo. fixes #9167 for 2.7

git-svn-id: http://svn.automattic.com/wordpress/branches/2.7@10599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-02-19 19:17:22 +00:00
parent c3b88c06ae
commit 9721bf8f00

View File

@ -1789,10 +1789,6 @@ class WP_Query {
$q['cat'] = implode(',', $req_cats);
}
if ( !empty($q['category__in']) ) {
$groupby = "{$wpdb->posts}.ID";
}
if ( !empty($q['category__in']) ) {
$join = " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) ";
$whichcat .= " AND $wpdb->term_taxonomy.taxonomy = 'category' ";
@ -1869,7 +1865,7 @@ class WP_Query {
}
}
if ( !empty($q['tag__in']) || !empty($q['tag_slug__in']) ) {
if ( !empty($q['category__in']) || !empty($q['meta_key']) || !empty($q['tag__in']) || !empty($q['tag_slug__in']) ) {
$groupby = "{$wpdb->posts}.ID";
}