From 6129438ba58a45cebe63b26698a9b9f70130f99a Mon Sep 17 00:00:00 2001 From: dd32 Date: Mon, 4 Oct 2010 08:56:04 +0000 Subject: [PATCH] Cache terms under more scenario's in update_post_caches(). Fixes #15026 git-svn-id: http://svn.automattic.com/wordpress/trunk@15700 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 48ab0c3a4..599a9ed45 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4096,8 +4096,21 @@ function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = t if ( empty($post_type) ) $post_type = 'post'; - if ( !is_array($post_type) && 'any' != $post_type && $update_term_cache ) - update_object_term_cache($post_ids, $post_type); + if ( $update_term_cache ) { + if ( is_array($post_type) ) { + $ptypes = $post_type; + } elseif ( 'any' == $post_type ) { + // Just use the post_types in the supplied posts. + foreach ( $posts as $post ) + $ptypes[] = $post->post_type; + $ptypes = array_unique($ptypes); + } else { + $ptypes = array($post_type); + } + + if ( ! empty($ptypes) ) + update_object_term_cache($post_ids, $ptypes); + } if ( $update_meta_cache ) update_postmeta_cache($post_ids);