WordPress.org

Make WordPress Core

Ticket #12766: post.php

File post.php, 1.1 KB (added by briancolinger, 10 years ago)
Line 
1Index: ../Sites/wordpress-trunk/wp-includes/post.php
2===================================================================
3--- ../Sites/wordpress-trunk/wp-includes/post.php       (revision 13885)
4+++ ../Sites/wordpress-trunk/wp-includes/post.php       (working copy)
5@@ -1650,11 +1650,13 @@
6        // Point all attachments to this post up one level
7        $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
8 
9-       $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
10+       $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post->post_parent ));
11        if ( ! empty($comment_ids) ) {
12                do_action( 'delete_comment', $comment_ids );
13-               $in_comment_ids = "'" . implode("', '", $comment_ids) . "'";
14-               $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_ID IN($in_comment_ids)" );
15+               foreach ( $comment_ids as $comment_id ) {
16+                       $force_delete_comment = true;
17+                       wp_delete_comment( $comment_id, $force_delete_comment );
18+               }
19                do_action( 'deleted_comment', $comment_ids );
20        }
21