Ticket #16742: 16742.2.diff
| File 16742.2.diff, 2.9 KB (added by ryan, 2 years ago) |
|---|
-
wp-includes/query.php
1240 1240 var $query_vars_hash = false; 1241 1241 1242 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; 1250 1251 /** 1243 1252 * Resets query flags to false. 1244 1253 * 1245 1254 * The query flags are what page info WordPress was able to figure out. … … 1395 1404 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']) ) 1400 1410 $this->is_robots = true; … … 1628 1638 $this->set_404(); 1629 1639 1630 1640 do_action_ref_array('parse_query', array(&$this)); 1641 1642 $this->query_vars_hash = md5( serialize( $this->query_vars ) ); 1631 1643 } 1632 1644 1633 1645 /* … … 1685 1697 } 1686 1698 1687 1699 // Category stuff 1688 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && md5(serialize( $this->query_vars ) ) != $this->query_vars_hash) {1700 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) { 1689 1701 $q['cat'] = ''.urldecode($q['cat']).''; 1690 1702 $q['cat'] = addslashes_gpc($q['cat']); 1691 1703 $cat_array = preg_split('/[,\s]+/', $q['cat']); … … 1739 1751 } 1740 1752 1741 1753 // Tag stuff 1742 if ( '' != $q['tag'] && !$this->is_singular && md5(serialize( $this->query_vars ) ) != $this->query_vars_hash) {1754 if ( '' != $q['tag'] && !$this->is_singular && $this->query_vars_changed ) { 1743 1755 if ( strpos($q['tag'], ',') !== false ) { 1744 1756 $tags = preg_split('/[,\s]+/', $q['tag']); 1745 1757 foreach ( (array) $tags as $tag ) { … … 1811 1823 ); 1812 1824 } 1813 1825 1814 $this->query_vars_hash = md5(serialize( $this->query_vars ) );1815 1816 1826 $this->tax_query = new WP_Tax_Query( $tax_query ); 1817 1827 } 1818 1828 … … 1884 1894 1885 1895 $q = $this->fill_query_vars($q); 1886 1896 1897 // Set a flag if a pre_get_posts hook change the query vars. 1898 $hash = md5( serialize( $this->query_vars ) ); 1899 $this->query_vars_changed = false; 1900 if ( $hash != $this->query_vars_hash ) { 1901 $this->query_vars_changed = true; 1902 $this->query_vars_hash = $hash; 1903 } 1904 unset($hash); 1905 1887 1906 // First let's clear some variables 1888 1907 $distinct = ''; 1889 1908 $whichauthor = ''; … … 2444 2463 $where .= ')'; 2445 2464 } 2446 2465 2466 if ( $this->query_vars_changed ) { 2467 $meta_query_hash = md5( serialize( $q['meta_query'] ) ); 2468 $_meta_query = $q['meta_query']; 2469 unset( $q['meta_query'] ); 2470 _parse_meta_query( $q ); 2471 if ( md5( serialize( $q['meta_query'] ) ) != $meta_query_hash && is_array( $_meta_query ) ) 2472 $q['meta_query'] = array_merge( $_meta_query, $q['meta_query'] ); 2473 } 2474 2447 2475 if ( !empty( $q['meta_query'] ) ) { 2448 2476 $clauses = call_user_func_array( '_get_meta_sql', array( $q['meta_query'], 'post', $wpdb->posts, 'ID', &$this) ); 2449 2477 $join .= $clauses['join'];
