Make WordPress Core

Ticket #35075: 35075.diff

File 35075.diff, 4.5 KB (added by boonebgorges, 9 years ago)
  • src/wp-includes/class-wp-comment-query.php

    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 { 
    365365                        $this->meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this );
    366366                }
    367367
    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 ) );
    370369                $last_changed = wp_cache_get( 'last_changed', 'comment' );
    371370                if ( ! $last_changed ) {
    372371                        $last_changed = microtime();
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index cc8e843..4e3fa98 100644
    function get_pages( $args = array() ) { 
    44014401                return false;
    44024402        }
    44034403
    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 ) );
    44064405        $last_changed = wp_cache_get( 'last_changed', 'posts' );
    44074406        if ( ! $last_changed ) {
    44084407                $last_changed = microtime();
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index cd5b92a..46e0f9f 100644
    function get_terms( $taxonomies, $args = '' ) { 
    14921492
    14931493        $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
    14941494
    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 );
    14971496        $last_changed = wp_cache_get( 'last_changed', 'terms' );
    14981497        if ( ! $last_changed ) {
    14991498                $last_changed = microtime();
  • tests/phpunit/tests/comment/query.php

    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 { 
    16761676
    16771677        /**
    16781678         * @ticket 22400
     1679         * @ticket 35075
    16791680         */
    1680         public function test_comment_cache_key_should_ignore_custom_params() {
     1681        public function test_comment_cache_key_should_not_ignore_custom_query_vars() {
    16811682                global $wpdb;
    16821683
    16831684                $p = self::factory()->post->create();
    class Tests_Comment_Query extends WP_UnitTestCase { 
    16981699                        'foo' => 'bar',
    16991700                ) );
    17001701
    1701                 $this->assertSame( $num_queries, $wpdb->num_queries );
     1702                $this->assertNotEquals( $num_queries, $wpdb->num_queries );
    17021703        }
    17031704
    17041705        /**
  • tests/phpunit/tests/post/getPages.php

    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 { 
    334334
    335335        }
    336336
     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
    337359        function test_wp_list_pages_classes() {
    338360                $type = 'taco';
    339361                register_post_type( $type, array( 'hierarchical' => true, 'public' => true ) );
  • tests/phpunit/tests/term/getTerms.php

    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 { 
    16651665
    16661666        }
    16671667
     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
    16681692        protected function create_hierarchical_terms_and_posts() {
    16691693                $terms = array();
    16701694