Make WordPress Core

Changeset 12428


Ignore:
Timestamp:
12/17/2009 05:10:40 PM (15 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r12420 r12428  
    823823    do_action('delete_comment', $comment_id);
    824824
    825     delete_comment_meta($comment_id,'_wp_trash_meta_status');
    826     delete_comment_meta($comment_id,'_wp_trash_meta_time');
    827 
    828825    if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
    829826        return false;
     
    834831        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));
    835832        clean_comment_cache($children);
     833    }
     834
     835    // Delete metadata
     836    $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) );
     837    if ( !empty($meta_ids) ) {
     838        do_action( 'delete_commentmeta', $meta_ids );
     839        $in_meta_ids = "'" . implode("', '", $meta_ids) . "'";
     840        $wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" );
     841        do_action( 'deleted_commentmeta', $meta_ids );
    836842    }
    837843
Note: See TracChangeset for help on using the changeset viewer.