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
This commit is contained in:
Andrew Nacin 2013-12-02 22:58:40 +00:00
parent f27ae94140
commit 2ec996d812
1 changed files with 8 additions and 2 deletions

View File

@ -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();