diff --git wp-includes/functions.php wp-includes/functions.php
index e7c8d44..a65898b 100644
|
|
function wp_allowed_protocols() { |
3654 | 3654 | |
3655 | 3655 | return $protocols; |
3656 | 3656 | } |
| 3657 | |
| 3658 | /** |
| 3659 | * Retrieve ids that are not already present in the cache |
| 3660 | * |
| 3661 | * @since 3.4.0 |
| 3662 | * |
| 3663 | * @param array $object_ids ID list |
| 3664 | * @param string $cache_key The cache bucket to check against |
| 3665 | * |
| 3666 | * @return array |
| 3667 | */ |
| 3668 | function _get_non_cached_ids( $object_ids, $cache_key ) { |
| 3669 | $clean = array(); |
| 3670 | foreach ( $object_ids as $id ) { |
| 3671 | $id = (int) $id; |
| 3672 | if ( !wp_cache_get( $id, $cache_key ) ) { |
| 3673 | $clean[] = $id; |
| 3674 | } |
| 3675 | } |
| 3676 | |
| 3677 | return $clean; |
| 3678 | } |
| 3679 | |
diff --git wp-includes/pluggable.php wp-includes/pluggable.php
index 030e453..dd5c126 100644
|
|
if ( !function_exists('cache_users') ) : |
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; |
diff --git wp-includes/query.php wp-includes/query.php
index bc6edea..9d5b5ca 100644
|
|
class WP_Query { |
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.' ) ); |
… |
… |
class WP_Query { |
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 ) ) |
… |
… |
class WP_Query { |
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 ); |
| 2637 | |
| 2638 | if ( $ids ) { |
| 2639 | if ( !$q['no_found_rows'] && !empty( $limits ) ) { |
| 2640 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
| 2641 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
| 2642 | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |
| 2643 | $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
| 2644 | } |
| 2645 | |
| 2646 | $non_cached_ids = _get_non_cached_ids( $ids, 'posts' ); |
| 2647 | |
| 2648 | if ( !empty( $non_cached_ids ) ) { |
| 2649 | $fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) ); |
| 2650 | |
| 2651 | update_post_caches($fresh_posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); |
| 2652 | } |
| 2653 | |
| 2654 | $this->posts = array(); |
| 2655 | |
| 2656 | foreach ( $ids as $id ) |
| 2657 | $this->posts[] = get_post( $id ); |
| 2658 | } else { |
| 2659 | $this->found_posts = $this->max_num_pages = 0; |
| 2660 | $this->posts = array(); |
| 2661 | } |
| 2662 | } else { |
| 2663 | $this->posts = $wpdb->get_results($this->request); |
| 2664 | } |
2630 | 2665 | |
2631 | 2666 | // Raw results filter. Prior to status checks. |
2632 | 2667 | if ( !$q['suppress_filters'] ) |
… |
… |
class WP_Query { |
2645 | 2680 | $this->comment_count = count($this->comments); |
2646 | 2681 | } |
2647 | 2682 | |
2648 | | if ( !$q['no_found_rows'] && !empty($limits) ) { |
| 2683 | if ( !$q['no_found_rows'] && !empty($limits) && !$expand_ids ) { |
2649 | 2684 | $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); |
2650 | 2685 | $this->found_posts = $wpdb->get_var( $found_posts_query ); |
2651 | 2686 | $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |