From 20301c4f6f3a9a5b342c392e2953e909928b6c0f Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 25 May 2016 18:29:28 +0000 Subject: [PATCH] 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 --- wp-includes/bookmark.php | 9 ++++++--- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index d2b98d9065..85142b2630 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 315ca95e21..022997eaaf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.