diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index af724ce021..e93fc428bd 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -431,8 +431,8 @@ function wp_delete_user($id, $reassign = 'novalue') { // FINALLY, delete user do_action('delete_user', $id); - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) ); + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) ); $user = new WP_User($id); diff --git a/wp-includes/post.php b/wp-includes/post.php index 15526bcf7f..8cc0d7b341 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1159,15 +1159,17 @@ function wp_delete_post($postid = 0) { foreach ( $revision_ids as $revision_id ) wp_delete_post_revision( $revision_id ); + do_action('deleted_post', $postid); + // Point all attachments to this post up one level $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) ); - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid )); $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $postid )); + $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); + if ( 'page' == $post->post_type ) { clean_page_cache($postid); @@ -1179,8 +1181,6 @@ function wp_delete_post($postid = 0) { clean_post_cache($postid); } - do_action('deleted_post', $postid); - return $post; } @@ -2516,12 +2516,12 @@ function wp_delete_attachment($postid) { /** @todo Delete for pluggable post taxonomies too */ wp_delete_object_term_relationships($postid, array('category', 'post_tag')); - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); - $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid )); $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid )); + $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); + $uploadPath = wp_upload_dir(); if ( ! empty($meta['thumb']) ) {