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
This commit is contained in:
Andrew Nacin 2013-12-02 22:59:10 +00:00
parent 67c504cf23
commit 6fa4ce2284

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