WordPress.org

Make WordPress Core

Changeset 12429


Ignore:
Timestamp:
12/17/09 17:11:21 (4 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.9/wp-includes/comment.php

    r12421 r12429  
    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.