Ticket #18536: 18536.5.diff
File 18536.5.diff, 5.4 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
5320 5320 wp_update_term_count( $tt_ids, $taxonomy ); 5321 5321 } 5322 5322 } 5323 5324 /** 5325 * Adds any posts from the given ids to the cache that do not already exist in cache 5326 * 5327 * @since 3.4.0 5328 * 5329 * @access private 5330 * @param array $post_ids ID list 5331 * @param bool $update_term_cache Whether to update the term cache. Default is true. 5332 * @param bool $update_meta_cache Whether to update the meta cache. Default is true. 5333 */ 5334 function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) { 5335 global $wpdb; 5336 5337 $non_cached_ids = _get_non_cached_ids( $ids, 'posts' ); 5338 if ( !empty( $non_cached_ids ) ) { 5339 $fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) ); 5340 update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); 5341 } 5342 } 5343 No newline at end of file -
wp-includes/functions.php
3699 3699 else 3700 3700 return $caller; 3701 3701 } 3702 3703 /** 3704 * Retrieve ids that are not already present in the cache 3705 * 3706 * @since 3.4.0 3707 * 3708 * @param array $object_ids ID list 3709 * @param string $cache_key The cache bucket to check against 3710 * 3711 * @return array 3712 */ 3713 function _get_non_cached_ids( $object_ids, $cache_key ) { 3714 $clean = array(); 3715 foreach ( $object_ids as $id ) { 3716 $id = (int) $id; 3717 if ( !wp_cache_get( $id, $cache_key ) ) { 3718 $clean[] = $id; 3719 } 3720 } 3721 3722 return $clean; 3723 } 3724 -
wp-includes/query.php
1951 1951 $fields = ''; 1952 1952 $post_status_join = false; 1953 1953 $page = 1; 1954 $expand_ids = false; 1954 1955 1955 1956 if ( isset( $q['caller_get_posts'] ) ) { 1956 1957 _deprecated_argument( 'WP_Query', '3.1', __( '"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.' ) ); … … 2597 2598 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; 2598 2599 } 2599 2600 2601 if ( "$wpdb->posts.*" == $fields ) { 2602 $fields = "$wpdb->posts.ID"; 2603 $expand_ids = true; 2604 } 2605 2600 2606 if ( ! empty($groupby) ) 2601 2607 $groupby = 'GROUP BY ' . $groupby; 2602 2608 if ( !empty( $orderby ) ) … … 2626 2632 return $r; 2627 2633 } 2628 2634 2629 $this->posts = $wpdb->get_results($this->request); 2635 if ( $expand_ids ) { 2636 $ids = $wpdb->get_col( $this->request ); 2630 2637 2638 if ( $ids ) { 2639 $this->set_found_posts( $q, $limits ); 2640 2641 _prime_post_caches($ids, $q['update_post_term_cache'], $q['update_post_meta_cache']); 2642 2643 $this->posts = array_map( 'get_post', $ids ); 2644 } else { 2645 $this->found_posts = $this->max_num_pages = 0; 2646 $this->posts = array(); 2647 } 2648 } else { 2649 $this->posts = $wpdb->get_results( $this->request ); 2650 $this->set_found_posts( $q, $limits ); 2651 } 2652 2631 2653 // Raw results filter. Prior to status checks. 2632 2654 if ( !$q['suppress_filters'] ) 2633 2655 $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); … … 2645 2667 $this->comment_count = count($this->comments); 2646 2668 } 2647 2669 2648 if ( !$q['no_found_rows'] && !empty($limits) ) {2649 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );2650 $this->found_posts = $wpdb->get_var( $found_posts_query );2651 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );2652 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);2653 }2654 2655 2670 // Check post status to determine if post should be displayed. 2656 2671 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 2657 2672 $status = get_post_status($this->posts[0]); … … 2754 2769 return $this->posts; 2755 2770 } 2756 2771 2772 function set_found_posts( $q, $limits ) { 2773 global $wpdb; 2774 2775 if ( $q['no_found_rows'] || empty( $limits ) ) 2776 return; 2777 2778 $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', $this ) ); 2779 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2780 $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, $this ) ); 2781 $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); 2782 } 2783 2757 2784 /** 2758 2785 * Set up the next post and iterate current post index. 2759 2786 * -
wp-includes/formatting.php
3019 3019 $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); 3020 3020 $urls_to_ping = implode( "\n", $urls_to_ping ); 3021 3021 return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); 3022 } 3022 } 3023 No newline at end of file -
wp-includes/pluggable.php
139 139 function cache_users( $user_ids ) { 140 140 global $wpdb; 141 141 142 $clean = array(); 143 foreach ( $user_ids as $id ) { 144 $id = (int) $id; 145 if ( !wp_cache_get( $id, 'users' ) ) { 146 $clean[] = $id; 147 } 148 } 142 $clean = _get_non_cached_ids( $user_ids, 'users' ); 149 143 150 144 if ( empty( $clean ) ) 151 145 return;