Make WordPress Core

Ticket #12611: update_post_caches.diff

File update_post_caches.diff, 1.2 KB (added by scribu, 15 years ago)

add 'cache_results' option

  • wp-includes/post.php

     
    39933993        update_post_cache($posts);
    39943994
    39953995        $post_ids = array();
     3996        foreach ( $posts as $post )
     3997                $post_ids[] = $post->ID;
    39963998
    3997         for ($i = 0; $i < count($posts); $i++)
    3998                 $post_ids[] = $posts[$i]->ID;
    3999 
    40003999        update_object_term_cache($post_ids, 'post');
    40014000
    40024001        update_postmeta_cache($post_ids);
  • wp-includes/query.php

     
    16261626                if ( !isset($q['suppress_filters']) )
    16271627                        $q['suppress_filters'] = false;
    16281628
     1629                if ( !isset($q['cache_results']) )
     1630                        $q['cache_results'] = true;
     1631
    16291632                if ( !isset($q['post_type']) ) {
    16301633                        if ( $this->is_search )
    16311634                                $q['post_type'] = 'any';
     
    24992502                        $this->posts[$i] = sanitize_post($this->posts[$i], 'raw');
    25002503                }
    25012504
    2502                 update_post_caches($this->posts);
     2505                if ( $q['cache_results'] )
     2506                        update_post_caches($this->posts);
    25032507
    25042508                if ($this->post_count > 0) {
    25052509                        $this->post = $this->posts[0];