Changeset 5666 for trunk/wp-includes/comment.php
- Timestamp:
- 06/08/2007 12:20:22 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r5329 r5666 72 72 // Handles comment caching. 73 73 function &get_comment(&$comment, $output = OBJECT) { 74 global $ comment_cache, $wpdb;74 global $wpdb; 75 75 76 76 if ( empty($comment) ) { … … 80 80 $_comment = null; 81 81 } elseif ( is_object($comment) ) { 82 if ( !isset($comment_cache[$comment->comment_ID]) ) 83 $comment_cache[$comment->comment_ID] = &$comment; 84 $_comment = & $comment_cache[$comment->comment_ID]; 82 wp_cache_add($comment->comment_ID, $comment, 'comment'); 83 $_comment = $comment; 85 84 } else { 86 85 $comment = (int) $comment; 87 86 if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { 88 87 $_comment = & $GLOBALS['comment']; 89 } elseif ( ! isset($comment_cache[$comment]) ) {88 } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { 90 89 $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1"); 91 $comment_cache[$comment->comment_ID] = & $_comment;92 } else {93 $_comment = & $comment_cache[$comment];94 } 95 }90 wp_cache_add($_comment->comment_ID, $_comment, 'comment'); 91 } 92 } 93 94 $_comment = apply_filters('get_comment', $_comment); 96 95 97 96 if ( $output == OBJECT ) { … … 286 285 wp_update_comment_count($post_id); 287 286 287 clean_comment_cache($comment_id); 288 288 289 do_action('wp_set_comment_status', $comment_id, 'delete'); 289 290 return true; … … 294 295 global $wpdb; 295 296 296 $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); 297 298 if ( $result == NULL ) 297 $comment = get_comment($comment_id); 298 if ( !$comment ) 299 return false; 300 301 $approved = $comment->comment_approved; 302 303 if ( $approved == NULL ) 299 304 return 'deleted'; 300 elseif ( $ result== '1' )305 elseif ( $approved == '1' ) 301 306 return 'approved'; 302 elseif ( $ result== '0' )307 elseif ( $approved == '0' ) 303 308 return 'unapproved'; 304 elseif ( $ result== 'spam' )309 elseif ( $approved == 'spam' ) 305 310 return 'spam'; 306 311 else … … 439 444 return false; 440 445 446 clean_comment_cache($comment_id); 447 441 448 do_action('wp_set_comment_status', $comment_id, $comment_status); 442 449 $comment = get_comment($comment_id); 443 450 wp_update_comment_count($comment->comment_post_ID); 451 444 452 return true; 445 453 } … … 480 488 481 489 $rval = $wpdb->rows_affected; 490 491 clean_comment_cache($comment_ID); 482 492 wp_update_comment_count($comment_post_ID); 483 493 do_action('edit_comment', $comment_ID); … … 794 804 } 795 805 806 // 807 // Cache 808 // 809 810 function clean_comment_cache($id) { 811 wp_cache_delete($id, 'comment'); 812 } 813 814 function update_comment_cache($comments) { 815 foreach ( $comments as $comment ) 816 wp_cache_add($comment->comment_ID, $comment, 'comment'); 817 } 818 796 819 ?>
Note: See TracChangeset
for help on using the changeset viewer.