WordPress.org

Make WordPress Core

Changeset 10851


Ignore:
Timestamp:
03/31/2009 07:16:53 PM (9 years ago)
Author:
ryan
Message:

Fix delete statements to ensure data integrity when innodb and foreign keys are used. Props Denis-de-Bernardy. see #9422

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/user.php

    r10810 r10851  
    432432    do_action('delete_user', $id);
    433433
     434    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    434435    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
    435     $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    436436
    437437    $user = new WP_User($id);
  • trunk/wp-includes/post.php

    r10810 r10851  
    11601160        wp_delete_post_revision( $revision_id );
    11611161
     1162    do_action('deleted_post', $postid);
     1163
    11621164    // Point all attachments to this post up one level
    11631165    $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
    11641166
     1167    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
     1168
     1169    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $postid ));
     1170
    11651171    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
    1166 
    1167     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    1168 
    1169     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $postid ));
    11701172
    11711173    if ( 'page' == $post->post_type ) {
     
    11791181        clean_post_cache($postid);
    11801182    }
    1181 
    1182     do_action('deleted_post', $postid);
    11831183
    11841184    return $post;
     
    25172517    wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
    25182518
     2519    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
     2520
     2521    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
     2522
    25192523    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
    2520 
    2521     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    2522 
    2523     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
    25242524
    25252525    $uploadPath = wp_upload_dir();
Note: See TracChangeset for help on using the changeset viewer.