WordPress.org

Make WordPress Core

Ticket #12766: commentmeta.patch

File commentmeta.patch, 1.9 KB (added by briancolinger, 5 years ago)
  • Sites/wordpress-trunk/wp-includes/post.php

     
    16531653        $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid )); 
    16541654        if ( ! empty($comment_ids) ) { 
    16551655                do_action( 'delete_comment', $comment_ids ); 
    1656                 $in_comment_ids = "'" . implode("', '", $comment_ids) . "'"; 
    1657                 $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_ID IN($in_comment_ids)" ); 
     1656                foreach ( $comment_ids as $comment_id ) { 
     1657                        $force_delete_comment = true; 
     1658                        wp_delete_comment( $comment_id, $force_delete_comment ); 
     1659                } 
    16581660                do_action( 'deleted_comment', $comment_ids ); 
    16591661        } 
    16601662 
  • Sites/wordpress-trunk/wp-includes/comment.php

     
    869869 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object 
    870870 * 
    871871 * @param int $comment_id Comment ID 
     872 * @param bool $force_delete Whether to bypass trash and force deletion 
    872873 * @return bool False if delete comment query failure, true on success. 
    873874 */ 
    874 function wp_delete_comment($comment_id) { 
     875function wp_delete_comment($comment_id, $force_delete = false) { 
    875876        global $wpdb; 
    876877        if (!$comment = get_comment($comment_id)) 
    877878                return false; 
    878879 
    879         if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) 
     880        if ( !$force_delete && wp_get_comment_status( $comment_id ) != 'trash' && wp_get_comment_status( $comment_id ) != 'spam' && EMPTY_TRASH_DAYS > 0 ) 
    880881                return wp_trash_comment($comment_id); 
    881882 
    882883        do_action('delete_comment', $comment_id);