mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 14:45:45 +01:00
Another query bites the dust!
git-svn-id: http://svn.automattic.com/wordpress/trunk@3219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
dced5779ea
commit
7c4d4cbec8
@ -1300,25 +1300,13 @@ function update_post_caches(&$posts) {
|
|||||||
for ($i = 0; $i < count($posts); $i++) {
|
for ($i = 0; $i < count($posts); $i++) {
|
||||||
$post_id_array[] = $posts[$i]->ID;
|
$post_id_array[] = $posts[$i]->ID;
|
||||||
$post_cache[$posts[$i]->ID] = &$posts[$i];
|
$post_cache[$posts[$i]->ID] = &$posts[$i];
|
||||||
|
$comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id_list = implode(',', $post_id_array);
|
$post_id_list = implode(',', $post_id_array);
|
||||||
|
|
||||||
update_post_category_cache($post_id_list);
|
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
|
// 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) ) {
|
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:
|
// Change from flat structure to hierarchical:
|
||||||
|
Loading…
Reference in New Issue
Block a user