Media: Fix deletion of files on Windows.

`wp_delete_file_from_directory()` should always normalize file paths before comparing.

Props tonybogdanov, SergeyBiryukov.
Merges [45352] to the 5.2 branch.
Fixes #47185.
Built from https://develop.svn.wordpress.org/branches/5.2@45353


git-svn-id: http://core.svn.wordpress.org/branches/5.2@45164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-05-17 13:31:53 +00:00
parent a582a30bf4
commit 2e6afd6f81
2 changed files with 11 additions and 3 deletions

View File

@ -6282,13 +6282,21 @@ function wp_delete_file( $file ) {
*/
function wp_delete_file_from_directory( $file, $directory ) {
if ( wp_is_stream( $file ) ) {
$real_file = wp_normalize_path( $file );
$real_directory = wp_normalize_path( $directory );
$real_file = $file;
$real_directory = $directory;
} else {
$real_file = realpath( wp_normalize_path( $file ) );
$real_directory = realpath( wp_normalize_path( $directory ) );
}
if ( false !== $real_file ) {
$real_file = wp_normalize_path( $real_file );
}
if ( false !== $real_directory ) {
$real_directory = wp_normalize_path( $real_directory );
}
if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) {
return false;
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.2.1-alpha-45351';
$wp_version = '5.2.1-alpha-45353';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.