Make WordPress Core

Ticket #9422: 9422.diff

File 9422.diff, 2.3 KB (added by Denis-de-Bernardy, 15 years ago)

fix delete statements to ensure data integrity when innodb and foreign keys are used

  • Users/denis/Sites/wp/wp-includes/post.php

     
    11591159        foreach ( $revision_ids as $revision_id )
    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
    1165         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
    1166 
    11671167        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    11681168
    11691169        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $postid ));
    11701170
     1171        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
     1172
    11711173        if ( 'page' == $post->post_type ) {
    11721174                clean_page_cache($postid);
    11731175
     
    11791181                clean_post_cache($postid);
    11801182        }
    11811183
    1182         do_action('deleted_post', $postid);
    1183 
    11841184        return $post;
    11851185}
    11861186
     
    25162516        /** @todo Delete for pluggable post taxonomies too */
    25172517        wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
    25182518
    2519         $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
    2520 
    25212519        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    25222520
    25232521        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
    25242522
     2523        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
     2524
    25252525        $uploadPath = wp_upload_dir();
    25262526
    25272527        if ( ! empty($meta['thumb']) ) {
  • Users/denis/Sites/wp/wp-admin/includes/user.php

     
    431431        // FINALLY, delete user
    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);
    438438