Changeset 9106

Show
Ignore:
Timestamp:
10/09/08 00:50:52 (2 months ago)
Author:
ryan
Message:

Suspend cache invalidation while importing posts with WP importer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/import/wordpress.php

    r9100 r9106  
    718718        $this->import_start(); 
    719719        $this->get_authors_from_post(); 
     720        wp_suspend_cache_invalidation(true); 
    720721        $this->get_entries(); 
    721722        $this->process_categories(); 
    722723        $this->process_tags(); 
    723724        $result = $this->process_posts(); 
     725        wp_suspend_cache_invalidation(false); 
    724726        $this->backfill_parents(); 
    725727        $this->backfill_attachment_urls(); 
  • trunk/wp-includes/functions.php

    r9051 r9106  
    28482848} 
    28492849 
     2850/** 
     2851 * Suspend cache invalidation. 
     2852 * 
     2853 * Turns cache invalidation on and off.  Useful during imports where you don't wont to do invalidations 
     2854 * every time a post is inserted.  Callers must be sure that what they are doing won't lead to an inconsistent 
     2855 * cache when invalidation is suspended. 
     2856 * 
     2857 * @since 2.7.0 
     2858 * 
     2859 * @param bool $suspend Whether to suspend or enable cache invalidation 
     2860 * @return bool The current suspend setting 
     2861 */ 
     2862function wp_suspend_cache_invalidation($suspend = true) { 
     2863    global $_wp_suspend_cache_invalidation; 
     2864 
     2865    $current_suspend = $_wp_suspend_cache_invalidation; 
     2866    $_wp_suspend_cache_invalidation = $suspend; 
     2867    return $current_suspend; 
     2868} 
     2869 
    28502870?> 
  • trunk/wp-includes/post.php

    r9101 r9106  
    28622862 */ 
    28632863function clean_post_cache($id) { 
    2864     global $wpdb; 
     2864    global $_wp_suspend_cache_invalidation, $wpdb; 
     2865 
     2866    if ( !empty($_wp_suspend_cache_invalidation) ) 
     2867        return; 
     2868 
    28652869    $id = (int) $id; 
    28662870