Make WordPress Core

Changeset 14310


Ignore:
Timestamp:
04/29/2010 08:43:59 PM (14 years ago)
Author:
nacin
Message:

Update object term cache for custom post types. props scribu, fixes #12989.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r14295 r14310  
    39833983 *
    39843984 * @param array $posts Array of Post objects
    3985  */
    3986 function update_post_caches(&$posts) {
     3985 * @param string $post_type The post type of the posts in $posts
     3986 */
     3987function update_post_caches(&$posts, $post_type = 'post') {
    39873988    // No point in doing all this work if we didn't match any posts.
    39883989    if ( !$posts )
     
    39923993
    39933994    $post_ids = array();
    3994 
    3995     for ($i = 0; $i < count($posts); $i++)
    3996         $post_ids[] = $posts[$i]->ID;
    3997 
    3998     update_object_term_cache($post_ids, 'post');
     3995    foreach ( $posts as $post )
     3996        $post_ids[] = $post->ID;
     3997
     3998    if ( empty($post_type) )
     3999        $post_type = 'post';
     4000
     4001    if ( !is_array($post_type) && 'any' != $post_type )
     4002        update_object_term_cache($post_ids, $post_type);
    39994003
    40004004    update_postmeta_cache($post_ids);
  • trunk/wp-includes/query.php

    r14245 r14310  
    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 )
     
    25052508        }
    25062509
    2507         update_post_caches($this->posts);
     2510        if ( $q['cache_results'] )
     2511            update_post_caches($this->posts, $post_type);
    25082512
    25092513        if ($this->post_count > 0) {
Note: See TracChangeset for help on using the changeset viewer.