Ticket #18356: 18356.diff
File 18356.diff, 1.8 KB (added by , 14 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 'expiration' => 600 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 135 if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 133 if ( is_array($cache) && isset( $cache[ $key ] ) ) 134 return apply_filters('get_bookmarks', $cache[ $key ], $r ); 136 if ( is_array($cache) && isset( $cache[ $key ] ) ) { 137 if ( $orderby == 'rand' ) { 138 if ( is_array( $cache[ $key ] ) && isset( $cache[ $key ][ 'results' ] ) && isset( $cache[ $key ][ 'expires' ] ) && $cache[ $key ][ 'expires' ] > time() ) 139 return apply_filters('get_bookmarks', $cache[ $key ][ 'results' ], $r ); 140 } else { 141 return apply_filters('get_bookmarks', $cache[ $key ], $r ); 142 } 143 } 135 144 } 136 145 137 146 if ( !is_array($cache) ) … … 252 261 253 262 $results = $wpdb->get_results($query); 254 263 255 $cache[ $key ] = $results; 264 if( $orderby == 'rand()' ) 265 $cache[ $key ] = array( 'expires' => time() + $expiration, 'results' => $results ); 266 else 267 $cache[ $key ] = $results; 268 256 269 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 257 270 258 271 return apply_filters('get_bookmarks', $results, $r);