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

Props joemcgill, dd32.
Fixes #42963 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@42433 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2018-01-10 06:09:51 +00:00
parent 70a92ca96e
commit 91b3164ee5
1 changed files with 5 additions and 1 deletions

View File

@ -1143,7 +1143,11 @@ function update_core( $from, $to ) {
if ( ! $wp_filesystem->exists( $old_file ) ) {
continue;
}
$wp_filesystem->delete( $old_file, true );
// If the file isn't deleted, try writing an empty string to the file instead.
if ( ! $wp_filesystem->delete( $old_file, true ) && $wp_filesystem->is_file( $old_file ) ) {
$wp_filesystem->put_contents( $old_file, '' );
}
}
// Remove any Genericons example.html's from the filesystem