WordPress.org

Make WordPress Core

Ticket #11463: 11463.diff

File 11463.diff, 1.1 KB (added by nacin, 8 years ago)
  • comment.php

     
    824824
    825825        do_action('delete_comment', $comment_id);
    826826
    827         delete_comment_meta($comment_id,'_wp_trash_meta_status');
    828         delete_comment_meta($comment_id,'_wp_trash_meta_time');
    829 
    830827        if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
    831828                return false;
    832829
     
    837834                clean_comment_cache($children);
    838835        }
    839836
     837        // Delete metadata
     838        $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) );
     839        if ( !empty($meta_ids) ) {
     840                do_action( 'delete_commentmeta', $meta_ids );
     841                $in_meta_ids = "'" . implode("', '", $meta_ids) . "'";
     842                $wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" );
     843                do_action( 'deleted_commentmeta', $meta_ids );
     844        }
     845
    840846        $post_id = $comment->comment_post_ID;
    841847        if ( $post_id && $comment->comment_approved == 1 )
    842848                wp_update_comment_count($post_id);