Make WordPress Core


Ignore:
Timestamp:
12/08/2006 07:35:45 AM (19 years ago)
Author:
ryan
Message:

Some caching cleanups.

File:
1 edited

Legend:

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

    r4626 r4631  
    431431    }
    432432
    433     if ( $wpdb->query($query) ) {
    434         do_action('wp_set_comment_status', $comment_id, $comment_status);
    435 
    436         $comment = get_comment($comment_id);
    437         $comment_post_ID = $comment->comment_post_ID;
    438         $c = $wpdb->get_row("SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
    439         if ( is_object($c) )
    440             $wpdb->query("UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'");
    441         return true;
    442     } else {
     433    if ( !$wpdb->query($query) )
    443434        return false;
    444     }
     435
     436    do_action('wp_set_comment_status', $comment_id, $comment_status);
     437    $comment = get_comment($comment_id);
     438    wp_update_comment_count($comment->comment_post_ID);
     439    return true;
    445440}
    446441
     
    491486    $wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'");
    492487    $comment_count_cache[$post_id] = $count;
     488
     489    $post = get_post($post_id);
     490    if ( 'page' == $post->post_type )
     491        clean_page_cache( $post_id );
     492    else
     493        clean_post_cache( $post_id );
     494
     495    do_action('edit_post', $post_id);
     496
    493497    return true;
    494498}
Note: See TracChangeset for help on using the changeset viewer.