WordPress.org

Make WordPress Core

Changeset 26543


Ignore:
Timestamp:
12/02/2013 10:58:40 PM (7 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r26329 r26543  
    23362336
    23372337    do_action( 'delete_post', $postid );
    2338     $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
     2338    $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
     2339    if ( ! $result ) {
     2340        return false;
     2341    }
    23392342    do_action( 'deleted_post', $postid );
    23402343
     
    41824185
    41834186    do_action( 'delete_post', $post_id );
    4184     $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
     4187    $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
     4188    if ( ! $result ) {
     4189        return false;
     4190    }
    41854191    do_action( 'deleted_post', $post_id );
    41864192
Note: See TracChangeset for help on using the changeset viewer.