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

Props lukecavanagh, prettyboymp, c3mdigital, MikeHansenMe.
Fixes #18356.
Built from https://develop.svn.wordpress.org/trunk@37565


git-svn-id: http://core.svn.wordpress.org/trunk@37533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-05-25 18:29:28 +00:00
parent e7e20e4b54
commit 20301c4f6f
2 changed files with 7 additions and 4 deletions

View File

@ -128,7 +128,8 @@ function get_bookmarks( $args = '' ) {
$r = wp_parse_args( $args, $defaults );
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
$cache = false;
if ( 'rand' !== $r['orderby'] && $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
$bookmarks = $cache[ $key ];
/**
@ -285,8 +286,10 @@ function get_bookmarks( $args = '' ) {
$results = $wpdb->get_results( $query );
$cache[ $key ] = $results;
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
if ( 'rand()' !== $orderby ) {
$cache[ $key ] = $results;
wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
}
/** This filter is documented in wp-includes/bookmark.php */
return apply_filters( 'get_bookmarks', $results, $r );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-alpha-37564';
$wp_version = '4.6-alpha-37565';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.