Delete all comment meta when deleting a comment. Props nacin. fixes #11463

git-svn-id: https://develop.svn.wordpress.org/trunk@12428 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-12-17 17:10:40 +00:00
parent dbad0d7271
commit 3820e511a6

View File

@ -822,9 +822,6 @@ function wp_delete_comment($comment_id) {
do_action('delete_comment', $comment_id);
delete_comment_meta($comment_id,'_wp_trash_meta_status');
delete_comment_meta($comment_id,'_wp_trash_meta_time');
if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
return false;
@ -835,6 +832,15 @@ function wp_delete_comment($comment_id) {
clean_comment_cache($children);
}
// Delete metadata
$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) );
if ( !empty($meta_ids) ) {
do_action( 'delete_commentmeta', $meta_ids );
$in_meta_ids = "'" . implode("', '", $meta_ids) . "'";
$wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" );
do_action( 'deleted_commentmeta', $meta_ids );
}
$post_id = $comment->comment_post_ID;
if ( $post_id && $comment->comment_approved == 1 )
wp_update_comment_count($post_id);