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

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

git-svn-id: https://develop.svn.wordpress.org/trunk@37565 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-05-25 18:29:01 +00:00
parent a27b379144
commit 1d3511ba8c
2 changed files with 29 additions and 3 deletions
@@ -47,4 +47,27 @@ class Tests_Bookmark_GetBookmarks extends WP_UnitTestCase {
$this->assertEqualSets( $bookmarks, wp_list_pluck( $found2, 'link_id' ) );
$this->assertTrue( $num_queries < $wpdb->num_queries );
}
/**
* @ticket 18356
*/
public function test_orderby_rand_should_not_be_cached() {
global $wpdb;
$bookmarks = self::factory()->bookmark->create_many( 2 );
$found1 = get_bookmarks( array(
'orderby' => 'rand',
) );
$num_queries = $wpdb->num_queries;
$found2 = get_bookmarks( array(
'orderby' => 'rand',
) );
// equal sets != same order
$this->assertEqualSets( $found1, $found2 );
$this->assertTrue( $num_queries < $wpdb->num_queries );
}
}