Ticket #18356: 18356.2.diff
File 18356.2.diff, 1.6 KB (added by , 13 years ago) |
---|
-
wp-includes/bookmark.php
105 105 * separated by commas. 106 106 * 'exclude' - Default is empty string (string). Exclude other categories 107 107 * separated by commas. 108 * 'expiration' - Default is 600 (integer). Lifetime of result cache when ordering 109 * by 'rand' 108 110 * 109 111 * @since 2.1.0 110 112 * @uses $wpdb Database Object … … 121 123 'limit' => -1, 'category' => '', 122 124 'category_name' => '', 'hide_invisible' => 1, 123 125 'show_updated' => 0, 'include' => '', 124 'exclude' => '', 'search' => '' 126 'exclude' => '', 'search' => '', 127 'expire' => 60 125 128 ); 126 129 127 130 $r = wp_parse_args( $args, $defaults ); 128 131 extract( $r, EXTR_SKIP ); 129 132 130 133 $cache = array(); 131 134 $key = md5( serialize( $r ) ); 132 if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 135 if ( $orderby == 'rand' ) { 136 if( $results = wp_cache_get( $key, 'get_bookmarks_rand' ) ) 137 return apply_filters('get_bookmarks', $results, $r ); 138 } elseif ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 133 139 if ( is_array($cache) && isset( $cache[ $key ] ) ) 134 140 return apply_filters('get_bookmarks', $cache[ $key ], $r ); 135 141 } … … 252 258 253 259 $results = $wpdb->get_results($query); 254 260 255 $cache[ $key ] = $results; 256 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 261 if( $orderby == 'rand()' ) { 262 wp_cache_set( $key, $results, 'get_bookmarks_rand', $expire ); 263 } else { 264 $cache[ $key ] = $results; 265 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 266 } 257 267 258 268 return apply_filters('get_bookmarks', $results, $r); 259 269 }