mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Fix delete statements to ensure data integrity when innodb and foreign keys are used. Props Denis-de-Bernardy. see #9422
git-svn-id: http://svn.automattic.com/wordpress/trunk@10851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
533114e89f
commit
f84839d5af
@ -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);
|
||||
|
||||
|
@ -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']) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user