From 1d59873acee6a3b4e39a21a20e8fde96e0ccfa2c Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 10 Jan 2018 06:10:47 +0000 Subject: [PATCH] Upgrade: When deleting old files, if deletion fails attempt to empty the file instead. Props joemcgill, dd32. Fixes #42963 for trunk. Built from https://develop.svn.wordpress.org/trunk@42433 git-svn-id: http://core.svn.wordpress.org/trunk@42263 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/update-core.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index ec909143dd..fc6681acb3 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -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 diff --git a/wp-includes/version.php b/wp-includes/version.php index 937d54af6d..f4b8fd2fb0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42432'; +$wp_version = '5.0-alpha-42433'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.