Make WordPress Core


Ignore:
Timestamp:
04/04/2010 12:42:34 PM (17 years ago)
Author:
nacin
Message:

Use the API to remove comments when deleting a post. Cleans up comment meta in the process. fixes #12766, props briancolinger

File:
1 edited

Legend:

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

    r13995 r13997  
    16651665        if ( ! empty($comment_ids) ) {
    16661666                do_action( 'delete_comment', $comment_ids );
    1667                 $in_comment_ids = "'" . implode("', '", $comment_ids) . "'";
    1668                 $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_ID IN($in_comment_ids)" );
     1667                foreach ( $comment_ids as $comment_id )
     1668                        wp_delete_comment( $comment_id, true );
    16691669                do_action( 'deleted_comment', $comment_ids );
    16701670        }
    … …  
    33513351
    33523352        $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
    3353         if ( ! empty($comment_ids) ) {
     3353        if ( ! empty( $comment_ids ) ) {
    33543354                do_action( 'delete_comment', $comment_ids );
    3355                 $in_comment_ids = "'" . implode("', '", $comment_ids) . "'";
    3356                 $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_ID IN($in_comment_ids)" );
     3355                foreach ( $comment_ids as $comment_id )
     3356                        wp_delete_comment( $comment_id, true );
    33573357                do_action( 'deleted_comment', $comment_ids );
    33583358        }
Note: See TracChangeset for help on using the changeset viewer.