mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Comments: Avoid reparenting during post deletion.
Delete comments in a descending order by comment ID when deleting a post. This avoids the expense of additional database queries required to re-parent threaded comments that are themselves about to be deleted. Props Mte90, andraganescu, johnbillion, hellofromTonya, peterwilsoncc. Fixes #37703. git-svn-id: https://develop.svn.wordpress.org/trunk@52015 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
243149b2c0
commit
4a67a9774a
@ -3236,7 +3236,7 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
|
||||
|
||||
wp_defer_comment_counting( true );
|
||||
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ) );
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $postid ) );
|
||||
foreach ( $comment_ids as $comment_id ) {
|
||||
wp_delete_comment( $comment_id, true );
|
||||
}
|
||||
@ -6194,7 +6194,7 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
||||
|
||||
wp_defer_comment_counting( true );
|
||||
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $post_id ) );
|
||||
foreach ( $comment_ids as $comment_id ) {
|
||||
wp_delete_comment( $comment_id, true );
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user