From 2ec996d812e418f37741782a6f36767984295489 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 2 Dec 2013 22:58:40 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@26543 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 2546ac2dc8..302002961b 100644 --- a/src/wp-includes/post.php +++ b/src/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();