Make WordPress Core


Ignore:
Timestamp:
05/25/2016 06:29:01 PM (9 years ago)
Author:
boonebgorges
Message:

In get_bookmarks(), don't cache if 'orderby=rand'.

Props lukecavanagh, prettyboymp, c3mdigital, MikeHansenMe.
Fixes #18356.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/bookmark/getBookmarks.php

    r37563 r37565  
    4848        $this->assertTrue( $num_queries < $wpdb->num_queries );
    4949    }
     50
     51    /**
     52     * @ticket 18356
     53     */
     54    public function test_orderby_rand_should_not_be_cached() {
     55        global $wpdb;
     56
     57        $bookmarks = self::factory()->bookmark->create_many( 2 );
     58
     59        $found1 = get_bookmarks( array(
     60            'orderby' => 'rand',
     61        ) );
     62
     63        $num_queries = $wpdb->num_queries;
     64
     65        $found2 = get_bookmarks( array(
     66            'orderby' => 'rand',
     67        ) );
     68
     69        // equal sets != same order
     70        $this->assertEqualSets( $found1, $found2 );
     71        $this->assertTrue( $num_queries < $wpdb->num_queries );
     72    }
    5073}
Note: See TracChangeset for help on using the changeset viewer.