Changeset 5666
- Timestamp:
- 06/08/2007 12:20:22 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-comments.php
r5508 r5666 152 152 </thead>'; 153 153 foreach ($comments as $comment) { 154 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 154 $post = get_post($comment->comment_post_ID); 155 $authordata = get_userdata($post->post_author); 155 156 $comment_status = wp_get_comment_status($comment->comment_ID); 156 157 $class = ('alternate' == $class) ? '' : 'alternate'; -
trunk/wp-admin/includes/template.php
r5637 r5666 251 251 } 252 252 253 update_comment_cache($comments); 254 253 255 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); 254 256 … … 261 263 $comment =& get_comment( $id ); 262 264 $class = ''; 263 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 265 $post = get_post($comment->comment_post_ID); 266 $authordata = get_userdata($post->post_author); 264 267 $comment_status = wp_get_comment_status($comment->comment_ID); 265 268 if ( 'unapproved' == $comment_status ) -
trunk/wp-includes/cache.php
r5544 r5666 64 64 var $non_existant_objects = array (); 65 65 var $global_groups = array ('users', 'userlogins', 'usermeta'); 66 var $non_persistent_groups = array('comment'); 66 67 var $blog_id; 67 68 var $cold_cache_hits = 0; … … 309 310 $errors = 0; 310 311 foreach ($this->dirty_objects as $group => $ids) { 312 if ( in_array($group, $this->non_persistent_groups) ) 313 continue; 314 311 315 $group_dir = $this->make_group_dir($group, $dir_perms); 312 316 -
trunk/wp-includes/comment-template.php
r5626 r5666 302 302 $comments = $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 303 303 $wp_query->comment_count = count($wp_query->comments); 304 update_comment_cache($comments); 304 305 305 306 define('COMMENTS_TEMPLATE', true); -
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.