From 275888f2e66d99f65397e318a719b5e44367dd9e Mon Sep 17 00:00:00 2001 From: scribu Date: Wed, 17 Nov 2010 02:04:08 +0000 Subject: [PATCH] Re-introduce ->tax_query as a read-only var. See #12891 git-svn-id: http://svn.automattic.com/wordpress/trunk@16414 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 2 +- wp-includes/query.php | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 9513e4caf..ff3693791 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -146,7 +146,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) $term_count = 0; - foreach ( $wp_query->get('tax_query') as $tax_query ) + foreach ( $wp_query->tax_query as $tax_query ) $term_count += count( $tax_query['terms'] ); $obj = $wp_query->get_queried_object(); diff --git a/wp-includes/query.php b/wp-includes/query.php index d9d435be8..e5e6e7bb8 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -708,6 +708,15 @@ class WP_Query { */ var $query_vars = array(); + /** + * Taxonomy query, as passed to get_tax_sql() + * + * @since 3.1.0 + * @access public + * @var array + */ + var $tax_query = array(); + /** * Holds the data for a single object that is queried. * @@ -1931,9 +1940,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'] ) ) { - $clauses = call_user_func_array( 'get_tax_sql', array( $q['tax_query'], $wpdb->posts, 'ID', &$this) ); + $this->tax_query = $this->parse_tax_query( $q ); + if ( !empty( $this->tax_query ) ) { + $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); $join .= $clauses['join']; $where .= $clauses['where']; @@ -1946,7 +1955,7 @@ class WP_Query { } // Back-compat - $tax_query_in = wp_list_filter( $q['tax_query'], array( 'operator' => 'IN' ) ); + $tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) ); if ( !empty( $tax_query_in ) ) { if ( !isset( $q['taxonomy'] ) ) { foreach ( $tax_query_in as $a_tax_query ) { @@ -2646,10 +2655,8 @@ class WP_Query { $this->queried_object = NULL; $this->queried_object_id = 0; - $tax_query = $this->get('tax_query'); - - if ( !empty( $tax_query ) ) { - $query = reset( $tax_query ); + if ( !empty( $this->tax_query ) ) { + $query = reset( $this->tax_query ); if ( 'term_id' == $query['field'] ) $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );