From 690cd434d1c1223302816f99b9b78a5abda86d02 Mon Sep 17 00:00:00 2001 From: scribu Date: Tue, 16 Nov 2010 16:22:09 +0000 Subject: [PATCH] Don't pollute the 'tax_query' query var. See #12891 git-svn-id: http://svn.automattic.com/wordpress/trunk@16402 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 9 +++++---- wp-includes/taxonomy.php | 6 ++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 81601aac9..da525f5e7 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1931,8 +1931,9 @@ class WP_Query { $search = apply_filters_ref_array('posts_search', array( $search, &$this ) ); // Taxonomies - $q['tax_query'] = $this->parse_tax_query( $q ); - if ( !empty( $q['tax_query'] ) ) { + $tax_query = $this->parse_tax_query( $q ); + + if ( !empty( $tax_query ) ) { if ( empty($post_type) ) { $post_type = 'any'; $post_status_join = true; @@ -1940,10 +1941,10 @@ class WP_Query { $post_status_join = true; } - $where .= get_tax_sql( $q['tax_query'], "$wpdb->posts.ID" ); + $where .= get_tax_sql( $tax_query, "$wpdb->posts.ID" ); // Back-compat - $tax_query_in = wp_list_filter( $q['tax_query'], array( 'operator' => 'IN' ) ); + $tax_query_in = wp_list_filter( $tax_query, array( 'operator' => 'IN' ) ); if ( !empty( $tax_query_in ) ) { if ( !isset( $q['taxonomy'] ) ) { foreach ( $tax_query_in as $a_tax_query ) { diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index bef3522e1..3cfc91efd 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -593,17 +593,15 @@ function get_tax_sql( $tax_query, $object_id_column ) { } if ( 1 == count( $sql ) ) { - $ids = $wpdb->get_col( $sql[0] ); + $r = $wpdb->get_col( $sql[0] ); } else { $r = "SELECT object_id FROM $wpdb->term_relationships WHERE 1=1"; foreach ( $sql as $query ) $r .= " AND object_id IN ($query)"; - - $ids = $wpdb->get_col( $r ); } if ( !empty( $ids ) ) - return " AND $object_id_column IN(" . implode( ', ', $ids ) . ")"; + return " AND $object_id_column IN($r)"; else return ' AND 0 = 1'; }