Changes from trunk/wp-includes/query.php at r17455 to branches/3.1/wp-includes/query.php at r17553
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/query.php
r17455 r17553 1232 1232 1233 1233 /** 1234 * Whether the tax query has been parsed once. 1234 * Stores the ->query_vars state like md5(serialize( $this->query_vars ) ) so we know 1235 * whether we have to re-parse because something has changed 1235 1236 * 1236 1237 * @since 3.1.0 1237 1238 * @access private 1238 * @var bool 1239 */ 1240 var $parsed_tax_query = false; 1239 */ 1240 var $query_vars_hash = false; 1241 1242 /** 1243 * Whether query vars have changed since the initial parse_query() call. Used to catch modifications to query vars made 1244 * via pre_get_posts hooks. 1245 * 1246 * @since 3.1.1 1247 * @access private 1248 */ 1249 var $query_vars_changed = true; 1241 1250 1242 1251 /** … … 1396 1405 $this->query_vars = $this->fill_query_vars($this->query_vars); 1397 1406 $qv = &$this->query_vars; 1407 $this->query_vars_changed = true; 1398 1408 1399 1409 if ( ! empty($qv['robots']) ) … … 1497 1507 } 1498 1508 1499 $this-> parsed_tax_query= false;1509 $this->query_vars_hash = false; 1500 1510 $this->parse_tax_query( $qv ); 1501 1511 … … 1628 1638 $this->set_404(); 1629 1639 1640 $this->query_vars_hash = md5( serialize( $this->query_vars ) ); 1641 $this->query_vars_changed = false; 1642 1630 1643 do_action_ref_array('parse_query', array(&$this)); 1631 1644 } … … 1655 1668 1656 1669 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) { 1670 if ( 'post_tag' == $taxonomy ) 1671 continue; // Handled further down in the $q['tag'] block 1672 1657 1673 if ( $t->query_var && !empty( $q[$t->query_var] ) ) { 1658 1674 $tax_query_defaults = array( … … 1683 1699 1684 1700 // Category stuff 1685 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && !$this->parsed_tax_query) {1701 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) { 1686 1702 $q['cat'] = ''.urldecode($q['cat']).''; 1687 1703 $q['cat'] = addslashes_gpc($q['cat']); … … 1737 1753 1738 1754 // Tag stuff 1739 if ( '' != $q['tag'] && !$this->is_singular && !$this->parsed_tax_query) {1755 if ( '' != $q['tag'] && !$this->is_singular && $this->query_vars_changed ) { 1740 1756 if ( strpos($q['tag'], ',') !== false ) { 1741 1757 $tags = preg_split('/[,\s]+/', $q['tag']); … … 1791 1807 1792 1808 if ( !empty($q['tag_slug__in']) ) { 1793 $q['tag_slug__in'] = array_map('sanitize_title', (array) $q['tag_slug__in']);1809 $q['tag_slug__in'] = array_map('sanitize_title', array_unique( (array) $q['tag_slug__in'] ) ); 1794 1810 $tax_query[] = array( 1795 1811 'taxonomy' => 'post_tag', … … 1800 1816 1801 1817 if ( !empty($q['tag_slug__and']) ) { 1802 $q['tag_slug__and'] = array_map('sanitize_title', (array) $q['tag_slug__and']);1818 $q['tag_slug__and'] = array_map('sanitize_title', array_unique( (array) $q['tag_slug__and'] ) ); 1803 1819 $tax_query[] = array( 1804 1820 'taxonomy' => 'post_tag', … … 1809 1825 } 1810 1826 1811 $this->parsed_tax_query = true;1812 1813 1827 $this->tax_query = new WP_Tax_Query( $tax_query ); 1814 1828 } … … 1880 1894 $q = &$this->query_vars; 1881 1895 1896 // Fill again in case pre_get_posts unset some vars. 1882 1897 $q = $this->fill_query_vars($q); 1898 1899 // Set a flag if a pre_get_posts hook changed the query vars. 1900 $hash = md5( serialize( $this->query_vars ) ); 1901 if ( $hash != $this->query_vars_hash ) { 1902 $this->query_vars_changed = true; 1903 $this->query_vars_hash = $hash; 1904 } 1905 unset($hash); 1883 1906 1884 1907 // First let's clear some variables … … 2148 2171 2149 2172 // Taxonomies 2150 $this->parse_tax_query( $q ); 2151 2152 $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' ); 2153 2154 $join .= $clauses['join']; 2155 $where .= $clauses['where']; 2173 if ( !$this->is_singular ) { 2174 $this->parse_tax_query( $q ); 2175 2176 $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' ); 2177 2178 $join .= $clauses['join']; 2179 $where .= $clauses['where']; 2180 } 2156 2181 2157 2182 if ( $this->is_tax ) { … … 2438 2463 2439 2464 $where .= ')'; 2465 } 2466 2467 // Parse the meta query again if query vars have changed. 2468 if ( $this->query_vars_changed ) { 2469 $meta_query_hash = md5( serialize( $q['meta_query'] ) ); 2470 $_meta_query = $q['meta_query']; 2471 unset( $q['meta_query'] ); 2472 _parse_meta_query( $q ); 2473 if ( md5( serialize( $q['meta_query'] ) ) != $meta_query_hash && is_array( $_meta_query ) ) 2474 $q['meta_query'] = array_merge( $_meta_query, $q['meta_query'] ); 2440 2475 } 2441 2476 … … 2893 2928 $this->queried_object = $term; 2894 2929 $this->queried_object_id = (int) $term->term_id; 2930 2931 if ( $this->is_category ) 2932 _make_cat_compat( $this->queried_object ); 2895 2933 } 2896 2934 } elseif ( $this->is_post_type_archive ) {
Note: See TracChangeset
for help on using the changeset viewer.