WordPress.org

Make WordPress Core

Changeset 36479


Ignore:
Timestamp:
02/05/2016 06:35:47 PM (6 years ago)
Author:
boonebgorges
Message:

Comments: Add 'parentin' and 'parentnot_in' to query var defaults.

Query var defaults are used to calculate a cache key. The fact that these
params were not listed among the defaults was causing cache keys to be
insufficiently specific.

Props danielbachhuber.
Fixes #35677.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r36381 r36479  
    274274            'order' => 'DESC',
    275275            'parent' => '',
     276            'parent__in' => '',
     277            'parent__not_in' => '',
    276278            'post_author__in' => '',
    277279            'post_author__not_in' => '',
  • trunk/tests/phpunit/tests/comment/query.php

    r36415 r36479  
    18661866
    18671867    /**
     1868     * @ticket 35677
     1869     */
     1870    public function test_cache_should_be_sensitive_to_parent__in() {
     1871        global $wpdb;
     1872
     1873        $q1 = new WP_Comment_Query( array(
     1874            'parent__in' => array( 1, 2, 3 ),
     1875        ) );
     1876
     1877        $num_queries = $wpdb->num_queries;
     1878
     1879        $q2 = new WP_Comment_Query( array(
     1880            'parent__in' => array( 4, 5, 6 ),
     1881        ) );
     1882
     1883        $this->assertNotEquals( $num_queries, $wpdb->num_queries );
     1884    }
     1885
     1886    /**
     1887     * @ticket 35677
     1888     */
     1889    public function test_cache_should_be_sensitive_to_parent__not_in() {
     1890        global $wpdb;
     1891
     1892        $q1 = new WP_Comment_Query( array(
     1893            'parent__not_in' => array( 1, 2, 3 ),
     1894        ) );
     1895
     1896        $num_queries = $wpdb->num_queries;
     1897
     1898        $q2 = new WP_Comment_Query( array(
     1899            'parent__not_in' => array( 4, 5, 6 ),
     1900        ) );
     1901
     1902        $this->assertNotEquals( $num_queries, $wpdb->num_queries );
     1903    }
     1904
     1905    /**
    18681906     * @ticket 32762
    18691907     */
Note: See TracChangeset for help on using the changeset viewer.