From 6fa4ce2284427502ad416b1dd291e591dc733a1f Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 2 Dec 2013 22:59:10 +0000 Subject: [PATCH] Return false from wp_delete_post() and wp_delete_attachment() if the DELETE is unsuccessful. This prevents attachments from being deleted off disk when a DB is locked and the delete is otherwise unsuccessful. fixes #25107. Built from https://develop.svn.wordpress.org/trunk@26543 git-svn-id: http://core.svn.wordpress.org/trunk@26435 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 2546ac2dc8..302002961b 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2335,7 +2335,10 @@ function wp_delete_post( $postid = 0, $force_delete = false ) { delete_metadata_by_mid( 'post', $mid ); do_action( 'delete_post', $postid ); - $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); + $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); + if ( ! $result ) { + return false; + } do_action( 'deleted_post', $postid ); clean_post_cache( $post ); @@ -4181,7 +4184,10 @@ function wp_delete_attachment( $post_id, $force_delete = false ) { delete_metadata_by_mid( 'post', $mid ); do_action( 'delete_post', $post_id ); - $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); + $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); + if ( ! $result ) { + return false; + } do_action( 'deleted_post', $post_id ); $uploadpath = wp_upload_dir();