diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php
index ac122a6..46485a6 100644
|
|
|
class WP_Comment_Query { |
| 365 | 365 | $this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this ); |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | | // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. |
| 369 | | $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) ); |
| | 368 | $key = md5( serialize( $this->query_vars ) ); |
| 370 | 369 | $last_changed = wp_cache_get( 'last_changed', 'comment' ); |
| 371 | 370 | if ( ! $last_changed ) { |
| 372 | 371 | $last_changed = microtime(); |
diff --git src/wp-includes/post.php src/wp-includes/post.php
index cc8e843..4e3fa98 100644
|
|
|
function get_pages( $args = array() ) { |
| 4401 | 4401 | return false; |
| 4402 | 4402 | } |
| 4403 | 4403 | |
| 4404 | | // $args can be whatever, only use the args defined in defaults to compute the key. |
| 4405 | | $key = md5( serialize( wp_array_slice_assoc( $r, array_keys( $defaults ) ) ) ); |
| | 4404 | $key = md5( serialize( $r ) ); |
| 4406 | 4405 | $last_changed = wp_cache_get( 'last_changed', 'posts' ); |
| 4407 | 4406 | if ( ! $last_changed ) { |
| 4408 | 4407 | $last_changed = microtime(); |
diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index cd5b92a..46e0f9f 100644
|
|
|
function get_terms( $taxonomies, $args = '' ) { |
| 1492 | 1492 | |
| 1493 | 1493 | $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits"; |
| 1494 | 1494 | |
| 1495 | | // $args can be anything. Only use the args defined in defaults to compute the key. |
| 1496 | | $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $query ); |
| | 1495 | $key = md5( serialize( $args ) . serialize( $taxonomies ) . $query ); |
| 1497 | 1496 | $last_changed = wp_cache_get( 'last_changed', 'terms' ); |
| 1498 | 1497 | if ( ! $last_changed ) { |
| 1499 | 1498 | $last_changed = microtime(); |
diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
index c00ceee..331fc34 100644
|
|
|
class Tests_Comment_Query extends WP_UnitTestCase { |
| 1676 | 1676 | |
| 1677 | 1677 | /** |
| 1678 | 1678 | * @ticket 22400 |
| | 1679 | * @ticket 35075 |
| 1679 | 1680 | */ |
| 1680 | | public function test_comment_cache_key_should_ignore_custom_params() { |
| | 1681 | public function test_comment_cache_key_should_not_ignore_custom_query_vars() { |
| 1681 | 1682 | global $wpdb; |
| 1682 | 1683 | |
| 1683 | 1684 | $p = self::factory()->post->create(); |
| … |
… |
class Tests_Comment_Query extends WP_UnitTestCase { |
| 1698 | 1699 | 'foo' => 'bar', |
| 1699 | 1700 | ) ); |
| 1700 | 1701 | |
| 1701 | | $this->assertSame( $num_queries, $wpdb->num_queries ); |
| | 1702 | $this->assertNotEquals( $num_queries, $wpdb->num_queries ); |
| 1702 | 1703 | } |
| 1703 | 1704 | |
| 1704 | 1705 | /** |
diff --git tests/phpunit/tests/post/getPages.php tests/phpunit/tests/post/getPages.php
index 5391815..fcd2827 100644
|
|
|
class Tests_Post_getPages extends WP_UnitTestCase { |
| 334 | 334 | |
| 335 | 335 | } |
| 336 | 336 | |
| | 337 | /** |
| | 338 | * @ticket 35075 |
| | 339 | */ |
| | 340 | public function test_cache_key_should_not_ignore_custom_query_vars() { |
| | 341 | global $wpdb; |
| | 342 | |
| | 343 | $page_id = self::factory()->post->create( array('post_type' => 'page') ); |
| | 344 | |
| | 345 | $p1 = get_pages( array( |
| | 346 | 'include' => $page_id, |
| | 347 | ) ); |
| | 348 | |
| | 349 | $num_queries = $wpdb->num_queries; |
| | 350 | |
| | 351 | $p1 = get_pages( array( |
| | 352 | 'include' => $page_id, |
| | 353 | 'foo' => 'bar', |
| | 354 | ) ); |
| | 355 | |
| | 356 | $this->assertNotEquals( $num_queries, $wpdb->num_queries ); |
| | 357 | } |
| | 358 | |
| 337 | 359 | function test_wp_list_pages_classes() { |
| 338 | 360 | $type = 'taco'; |
| 339 | 361 | register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) ); |
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index bcd3485..f45d726 100644
|
|
|
class Tests_Term_getTerms extends WP_UnitTestCase { |
| 1665 | 1665 | |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| | 1668 | /** |
| | 1669 | * @ticket 35075 |
| | 1670 | */ |
| | 1671 | public function test_cache_key_should_not_ignore_custom_query_vars() { |
| | 1672 | global $wpdb; |
| | 1673 | |
| | 1674 | $term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); |
| | 1675 | |
| | 1676 | $t1 = get_terms( 'category', array( |
| | 1677 | 'include' => $term_id, |
| | 1678 | 'fields' => 'ids', |
| | 1679 | ) ); |
| | 1680 | |
| | 1681 | $num_queries = $wpdb->num_queries; |
| | 1682 | |
| | 1683 | $t2 = get_terms( 'category', array( |
| | 1684 | 'include' => $term_id, |
| | 1685 | 'fields' => 'ids', |
| | 1686 | 'foo' => 'bar', |
| | 1687 | ) ); |
| | 1688 | |
| | 1689 | $this->assertNotEquals( $num_queries, $wpdb->num_queries ); |
| | 1690 | } |
| | 1691 | |
| 1668 | 1692 | protected function create_hierarchical_terms_and_posts() { |
| 1669 | 1693 | $terms = array(); |
| 1670 | 1694 | |