Another query bites the dust!

git-svn-id: https://develop.svn.wordpress.org/trunk@3219 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2005-11-28 09:37:17 +00:00
parent 062836b194
commit 0d88ea9ef8
1 changed files with 1 additions and 13 deletions

View File

@ -1300,25 +1300,13 @@ function update_post_caches(&$posts) {
for ($i = 0; $i < count($posts); $i++) {
$post_id_array[] = $posts[$i]->ID;
$post_cache[$posts[$i]->ID] = &$posts[$i];
$comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;
}
$post_id_list = implode(',', $post_id_array);
update_post_category_cache($post_id_list);
// Do the same for comment numbers
$comment_counts = $wpdb->get_results( "SELECT ID as comment_post_ID, comment_count as ccount FROM $wpdb->posts WHERE ID in ($post_id_list)" );
if ( $comment_counts ) {
foreach ($comment_counts as $comment_count) {
$comment_count_cache["$comment_count->comment_post_ID"] = $comment_count->ccount;
$has_comments[] = $comment_count->comment_post_ID;
}
$no_comments = array_diff( $post_id_array, $has_comments );
foreach ( $no_comments as $id )
$comment_count_cache["$id"] = 0;
}
// Get post-meta info
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical: