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
+6 -3
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 );