Changeset 6532
- Timestamp:
- 01/01/2008 05:03:52 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wordpress.php
r6477 r6532 377 377 } 378 378 379 if ($post_id = post_exists($post_title, '', $post_date)) { 379 $post_exists = post_exists($post_title, '', $post_date); 380 381 if ( $post_exists ) { 380 382 echo '<li>'; 381 383 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); … … 476 478 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 477 479 478 if ( !comment_exists($comment_author, $comment_date) ) { 480 // if this is a new post we can skip the comment_exists() check 481 if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) { 479 482 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 480 483 wp_insert_comment($commentdata); … … 649 652 } 650 653 654 function import_start() { 655 wp_defer_term_counting(true); 656 wp_defer_comment_counting(true); 657 do_action('import_start'); 658 } 659 660 function import_end() { 661 do_action('import_end'); 662 663 // clear the caches after backfilling 664 foreach ($this->post_ids_processed as $post_id) 665 clean_post_cache($post_id); 666 667 wp_defer_term_counting(false); 668 wp_defer_comment_counting(false); 669 } 651 670 652 671 function import($id, $fetch_attachments = false) { … … 655 674 656 675 add_filter('import_post_meta_key', array($this, 'is_valid_meta_key')); 657 do_action('import_start');658 676 $file = get_attached_file($this->id); 659 677 $this->import_file($file); 660 do_action('import_end');661 678 } 662 679 … … 664 681 $this->file = $file; 665 682 683 $this->import_start(); 666 684 $this->get_authors_from_post(); 667 wp_defer_term_counting(true);668 685 $this->get_entries(); 669 686 $this->process_categories(); … … 672 689 $this->backfill_parents(); 673 690 $this->backfill_attachment_urls(); 674 675 // clear the caches after backfilling 676 foreach ($this->post_ids_processed as $post_id) 677 clean_post_cache($post_id); 678 679 wp_defer_term_counting(false); 691 $this->import_end(); 692 680 693 if ( is_wp_error( $result ) ) 681 694 return $result; -
trunk/wp-includes/comment.php
r6364 r6532 492 492 } 493 493 494 495 function wp_update_comment_count($post_id) { 494 function wp_defer_comment_counting($defer=NULL) { 495 static $_defer = false; 496 497 if ( is_bool($defer) ) { 498 $_defer = $defer; 499 // flush any deferred counts 500 if ( !$defer ) 501 wp_update_comment_count( NULL, true ); 502 } 503 504 return $_defer; 505 } 506 507 function wp_update_comment_count($post_id, $do_deferred=false) { 508 static $_deferred = array(); 509 510 if ( $do_deferred ) { 511 $_deferred = array_unique($_deferred); 512 foreach ( $_deferred as $i => $_post_id ) { 513 wp_update_comment_count_now($_post_id); 514 unset( $_deferred[$i] ); 515 } 516 } 517 518 if ( wp_defer_comment_counting() ) { 519 $_deferred[] = $post_id; 520 return true; 521 } 522 elseif ( $post_id ) { 523 return wp_update_comment_count_now($post_id); 524 } 525 526 } 527 528 function wp_update_comment_count_now($post_id) { 496 529 global $wpdb; 497 530 $post_id = (int) $post_id;
Note: See TracChangeset
for help on using the changeset viewer.