diff --git wp-includes/functions.php wp-includes/functions.php
index 6f7030a..af6d99d 100644
|
|
|
function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr |
| 3703 | 3703 | else |
| 3704 | 3704 | return $caller; |
| 3705 | 3705 | } |
| | 3706 | |
| | 3707 | /** |
| | 3708 | * Retrieve ids that are not already present in the cache |
| | 3709 | * |
| | 3710 | * @since 3.4.0 |
| | 3711 | * |
| | 3712 | * @param array $object_ids ID list |
| | 3713 | * @param string $cache_key The cache bucket to check against |
| | 3714 | * |
| | 3715 | * @return array |
| | 3716 | */ |
| | 3717 | function _get_non_cached_ids( $object_ids, $cache_key ) { |
| | 3718 | $clean = array(); |
| | 3719 | foreach ( $object_ids as $id ) { |
| | 3720 | $id = (int) $id; |
| | 3721 | if ( !wp_cache_get( $id, $cache_key ) ) { |
| | 3722 | $clean[] = $id; |
| | 3723 | } |
| | 3724 | } |
| | 3725 | |
| | 3726 | return $clean; |
| | 3727 | } |
| | 3728 | |
diff --git wp-includes/pluggable.php wp-includes/pluggable.php
index a6b7b47..08623f5 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/post-thumbnail-template.php wp-includes/post-thumbnail-template.php
index b4cf8bf..ab8941f 100644
|
|
|
function update_post_thumbnail_cache() { |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if ( ! empty ( $thumb_ids ) ) { |
| 67 | | get_posts( array( |
| 68 | | 'update_post_term_cache' => false, |
| 69 | | 'include' => $thumb_ids, |
| 70 | | 'post_type' => 'attachment', |
| 71 | | 'post_status' => 'inherit', |
| 72 | | 'nopaging' => true |
| 73 | | ) ); |
| | 67 | _prime_post_caches( $thumb_ids, false, true ); |
| 74 | 68 | } |
| 75 | 69 | |
| 76 | 70 | $wp_query->thumbnails_cached = true; |
diff --git wp-includes/post.php wp-includes/post.php
index 2bdd51b..10cd1f4 100644
|
|
|
function _update_term_count_on_transition_post_status( $new_status, $old_status, |
| 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 | * |
| | 5331 | * @param array $post_ids ID list |
| | 5332 | * @param bool $update_term_cache Whether to update the term cache. Default is true. |
| | 5333 | * @param bool $update_meta_cache Whether to update the meta cache. Default is true. |
| | 5334 | */ |
| | 5335 | function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) { |
| | 5336 | global $wpdb; |
| | 5337 | |
| | 5338 | $non_cached_ids = _get_non_cached_ids( $ids, 'posts' ); |
| | 5339 | if ( !empty( $non_cached_ids ) ) { |
| | 5340 | $fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", join( ",", $non_cached_ids ) ) ); |
| | 5341 | |
| | 5342 | update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); |
| | 5343 | } |
| | 5344 | } |
| | 5345 | |
diff --git wp-includes/query.php wp-includes/query.php
index bc6edea..df60a66 100644
|
|
|
class WP_Query { |
| 2606 | 2606 | if ( !$q['no_found_rows'] && !empty($limits) ) |
| 2607 | 2607 | $found_rows = 'SQL_CALC_FOUND_ROWS'; |
| 2608 | 2608 | |
| 2609 | | $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 2610 | | if ( !$q['suppress_filters'] ) |
| 2611 | | $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); |
| | 2609 | $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| | 2610 | |
| | 2611 | if ( !$q['suppress_filters'] ) { |
| | 2612 | $this->request = apply_filters( 'posts_request', $this->request, $this ); |
| | 2613 | } |
| 2612 | 2614 | |
| 2613 | 2615 | if ( 'ids' == $q['fields'] ) { |
| 2614 | 2616 | $this->posts = $wpdb->get_col($this->request); |
| … |
… |
class WP_Query { |
| 2626 | 2628 | return $r; |
| 2627 | 2629 | } |
| 2628 | 2630 | |
| 2629 | | $this->posts = $wpdb->get_results($this->request); |
| | 2631 | if ( $old_request == $this->request && "$wpdb->posts.*" == $fields ) { |
| | 2632 | // First get the IDs and then fill in the objects |
| | 2633 | |
| | 2634 | $this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| | 2635 | |
| | 2636 | $this->request = apply_filters( 'posts_request_ids', $this->request, $this ); |
| | 2637 | |
| | 2638 | $ids = $wpdb->get_col( $this->request ); |
| | 2639 | |
| | 2640 | if ( $ids ) { |
| | 2641 | $this->set_found_posts( $q, $limits ); |
| | 2642 | |
| | 2643 | _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); |
| | 2644 | |
| | 2645 | $this->posts = array_map( 'get_post', $ids ); |
| | 2646 | } else { |
| | 2647 | $this->found_posts = $this->max_num_pages = 0; |
| | 2648 | $this->posts = array(); |
| | 2649 | } |
| | 2650 | } else { |
| | 2651 | $this->posts = $wpdb->get_results( $this->request ); |
| | 2652 | $this->set_found_posts( $q, $limits ); |
| | 2653 | } |
| 2630 | 2654 | |
| 2631 | 2655 | // Raw results filter. Prior to status checks. |
| 2632 | 2656 | if ( !$q['suppress_filters'] ) |
| … |
… |
class WP_Query { |
| 2645 | 2669 | $this->comment_count = count($this->comments); |
| 2646 | 2670 | } |
| 2647 | 2671 | |
| 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 | 2672 | // Check post status to determine if post should be displayed. |
| 2656 | 2673 | if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { |
| 2657 | 2674 | $status = get_post_status($this->posts[0]); |
| … |
… |
class WP_Query { |
| 2754 | 2771 | return $this->posts; |
| 2755 | 2772 | } |
| 2756 | 2773 | |
| | 2774 | function set_found_posts( $q, $limits ) { |
| | 2775 | global $wpdb; |
| | 2776 | |
| | 2777 | if ( $q['no_found_rows'] || empty( $limits ) ) |
| | 2778 | return; |
| | 2779 | |
| | 2780 | $this->found_posts = $wpdb->get_var( apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()', $this ) ); |
| | 2781 | $this->found_posts = apply_filters( 'found_posts', $this->found_posts, $this ); |
| | 2782 | |
| | 2783 | $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); |
| | 2784 | } |
| | 2785 | |
| 2757 | 2786 | /** |
| 2758 | 2787 | * Set up the next post and iterate current post index. |
| 2759 | 2788 | * |