Ticket #22176: 22176.2.diff
File 22176.2.diff, 2.7 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
4507 4507 wp_cache_delete( 'all_page_ids', 'posts' ); 4508 4508 do_action( 'clean_page_cache', $post->ID ); 4509 4509 } 4510 4511 if ( function_exists( 'wp_cache_incr' ) ) { 4512 wp_cache_incr( 'last_changed', 1, 'posts' ); 4513 } else { 4514 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 4515 wp_cache_set( 'last_changed', $last_changed + 1, 'posts' ); 4516 } 4510 4517 } 4511 4518 4512 4519 /** -
wp-includes/query.php
1279 1279 */ 1280 1280 var $thumbnails_cached = false; 1281 1281 1282 /** 1283 * The cache key for the posts_request_ids query cache. 1284 * 1285 * @since 3.6.0 1286 * @access private 1287 * @var string 1288 */ 1289 private $cache_key; 1290 1282 1291 /** 1283 1292 * Resets query flags to false. 1284 1293 * … … 2661 2670 2662 2671 $this->request = apply_filters( 'posts_request_ids', $this->request, $this ); 2663 2672 2664 $ids = $wpdb->get_col( $this->request ); 2673 $last_changed = wp_cache_get( 'last_changed', 'posts' ); 2674 if ( ! $last_changed ) 2675 $last_changed = wp_cache_set( 'last_changed', 1, 'posts' ); 2676 $this->cache_key = md5( $this->request ) . $last_changed; 2665 2677 2678 if ( ! $ids = wp_cache_get( $this->cache_key, 'posts' ) ) { 2679 $ids = $wpdb->get_col( $this->request ); 2680 wp_cache_set( $this->cache_key, $ids, 'posts' ); 2681 } 2682 2666 2683 if ( $ids ) { 2667 2684 $this->posts = $ids; 2668 2685 $this->set_found_posts( $q, $limits ); … … 2802 2819 if ( $q['no_found_rows'] || ! $this->posts ) 2803 2820 return; 2804 2821 2805 if ( ! empty( $limits ) ) 2806 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2807 else 2808 $this->found_posts = count( $this->posts ); 2822 if ( ! $this->cache_key || ! $this->found_posts = wp_cache_get( $this->cache_key . '_found', 'posts' ) ) { 2823 if ( ! empty( $limits ) ) 2824 $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); 2825 else 2826 $this->found_posts = count( $this->posts ); 2809 2827 2810 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );2828 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2811 2829 2830 wp_cache_set( $this->cache_key . '_found', $this->found_posts, 'posts' ); 2831 } else { 2832 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 2833 } 2834 2812 2835 if ( ! empty( $limits ) ) 2813 2836 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2814 2837 }