WordPress.org

Make WordPress Core

Changeset 42477


Ignore:
Timestamp:
01/16/2018 06:58:38 AM (3 years ago)
Author:
dd32
Message:

Upgrade: When deleting old files, if deletion fails attempt to empty the file instead.

Props joemcgill, dd32.
Merges [42434] to the 3.7 branch.
Fixes #42963 for 3.7.

Location:
branches/3.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-admin/includes/update-core.php

    r32411 r42477  
    879879        if ( !$wp_filesystem->exists($old_file) )
    880880            continue;
    881         $wp_filesystem->delete($old_file, true);
     881
     882        // If the file isn't deleted, try writing an empty string to the file instead.
     883        if ( ! $wp_filesystem->delete( $old_file, true ) && $wp_filesystem->is_file( $old_file ) ) {
     884            $wp_filesystem->put_contents( $old_file, '' );
     885        }
    882886    }
    883887
Note: See TracChangeset for help on using the changeset viewer.