Changeset 37565
- Timestamp:
- 05/25/2016 06:29:01 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/bookmark.php
r37542 r37565 129 129 130 130 $key = md5( serialize( $r ) ); 131 if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 131 $cache = false; 132 if ( 'rand' !== $r['orderby'] && $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) { 132 133 if ( is_array( $cache ) && isset( $cache[ $key ] ) ) { 133 134 $bookmarks = $cache[ $key ]; … … 286 287 $results = $wpdb->get_results( $query ); 287 288 288 $cache[ $key ] = $results; 289 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 289 if ( 'rand()' !== $orderby ) { 290 $cache[ $key ] = $results; 291 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 292 } 290 293 291 294 /** This filter is documented in wp-includes/bookmark.php */ -
trunk/tests/phpunit/tests/bookmark/getBookmarks.php
r37563 r37565 48 48 $this->assertTrue( $num_queries < $wpdb->num_queries ); 49 49 } 50 51 /** 52 * @ticket 18356 53 */ 54 public function test_orderby_rand_should_not_be_cached() { 55 global $wpdb; 56 57 $bookmarks = self::factory()->bookmark->create_many( 2 ); 58 59 $found1 = get_bookmarks( array( 60 'orderby' => 'rand', 61 ) ); 62 63 $num_queries = $wpdb->num_queries; 64 65 $found2 = get_bookmarks( array( 66 'orderby' => 'rand', 67 ) ); 68 69 // equal sets != same order 70 $this->assertEqualSets( $found1, $found2 ); 71 $this->assertTrue( $num_queries < $wpdb->num_queries ); 72 } 50 73 }
Note: See TracChangeset
for help on using the changeset viewer.