Make WordPress Core

Changeset 4631


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

Some caching cleanups.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-db.php

    r4534 r4631  
    134134    }
    135135
    136     wp_cache_delete($cat_ID, 'category');
    137     wp_cache_delete('get_categories', 'category');
     136    clean_category_cache($cat_ID);
    138137
    139138    if ($update) {
    140139        do_action('edit_category', $cat_ID);
    141140    } else {
    142         wp_cache_delete('all_category_ids', 'category');
    143141        do_action('create_category', $cat_ID);
    144142        do_action('add_category', $cat_ID);
     
    214212    }
    215213
    216     wp_cache_delete($cat_ID, 'category');
    217     wp_cache_delete('all_category_ids', 'category');
    218     wp_cache_delete('get_categories', 'category');
     214    clean_category_cache($cat_ID);
    219215
    220216    do_action('delete_category', $cat_ID);
     
    488484    }
    489485
    490     do_action('edit_link', $link_ID);
    491486}   // wp_set_link_cats()
    492487
  • 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}
  • trunk/wp-includes/functions.php

    r4628 r4631  
    520520
    521521function clean_post_cache($id) {
    522     global $post_cache, $blog_id;
     522    global $post_cache, $post_meta_cache, $category_cache, $blog_id;
    523523
    524524    if ( isset( $post_cache[$blog_id][$id] ) )
    525525        unset( $post_cache[$blog_id][$id] );
     526
     527    if ( isset ($post_meta_cache[$blog_id][$id] ) )
     528        unset( $post_meta_cache[$blog_id][$id] );
     529
     530    if ( isset( $category_cache[$blog_id][$id]) )
     531        unset ( $category_cache[$blog_id][$id] );
    526532}
    527533
     
    538544}
    539545
    540 
    541546function clean_page_cache($id) {
    542547    global $page_cache, $blog_id;
     
    544549    if ( isset( $page_cache[$blog_id][$id] ) )
    545550        unset( $page_cache[$blog_id][$id] );
     551
     552    wp_cache_delete($id, 'pages');
     553    wp_cache_delete( 'all_page_ids', 'pages' );
     554    wp_cache_delete( 'get_pages', 'page' );
    546555}
    547556
     
    648657function update_category_cache() {
    649658    return true;
     659}
     660
     661function clean_category_cache($id) {
     662    wp_cache_delete($id, 'category');
     663    wp_cache_delete('all_category_ids', 'category');
     664    wp_cache_delete('get_categories', 'category');
    650665}
    651666
  • trunk/wp-includes/post.php

    r4625 r4631  
    439439
    440440    if ( 'page' == $post->post_type ) {
    441         wp_cache_delete( 'all_page_ids', 'pages' );
    442         wp_cache_delete( 'get_pages', 'page' );
     441        clean_page_cache($postid);
    443442        $wp_rewrite->flush_rules();
    444443    }
     
    651650    if ( 'page' == $post_type ) {
    652651        clean_page_cache($post_ID);
    653         wp_cache_delete($post_ID, 'pages');
     652        $wp_rewrite->flush_rules();
    654653    } else {
    655654        clean_post_cache($post_ID);
     
    690689        }
    691690    } else if ($post_type == 'page') {
    692         wp_cache_delete( 'all_page_ids', 'pages' );
    693         wp_cache_delete( 'get_pages', 'page' );
    694         $wp_rewrite->flush_rules();
    695 
    696691        if ( !empty($page_template) )
    697692            if ( ! update_post_meta($post_ID, '_wp_page_template',  $page_template))
     
    817812        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
    818813        $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
    819         wp_cache_delete($cat_id, 'category');
     814        clean_category_cache($cat_id);
    820815        do_action('edit_category', $cat_id);
    821816    }
    822 
    823     wp_cache_delete('get_categories', 'category');
    824 
    825     do_action('edit_post', $post_ID);
    826817}   // wp_set_post_categories()
    827818
Note: See TracChangeset for help on using the changeset viewer.