mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 16:21:26 +01:00
Media: Fix deletion of files when using stream wrappers.
This fixes a bug introduced in [43392] which breaks file deletion on systems using stream wrappers, due to limitations of `realpath()`. Props antonypuckey, pfiled. Fixes #44563. Built from https://develop.svn.wordpress.org/trunk@45177 git-svn-id: http://core.svn.wordpress.org/trunk@44986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
30ccfd540f
commit
1b35ea6978
@ -1830,6 +1830,14 @@ function wp_mkdir_p( $target ) {
|
||||
* @return bool True if path is absolute, false is not absolute.
|
||||
*/
|
||||
function path_is_absolute( $path ) {
|
||||
/*
|
||||
* Check to see if the path is a stream and check to see if its an actual
|
||||
* path or file as realpath() does not support stream wrappers.
|
||||
*/
|
||||
if ( wp_is_stream( $path ) && ( is_dir( $path ) || is_file( $path ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is definitive if true but fails if $path does not exist or contains
|
||||
* a symbolic link.
|
||||
@ -6269,10 +6277,15 @@ function wp_delete_file( $file ) {
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function wp_delete_file_from_directory( $file, $directory ) {
|
||||
$real_file = realpath( wp_normalize_path( $file ) );
|
||||
$real_directory = realpath( wp_normalize_path( $directory ) );
|
||||
if ( wp_is_stream( $file ) ) {
|
||||
$real_file = wp_normalize_path( $file );
|
||||
$real_directory = wp_normalize_path( $directory );
|
||||
} else {
|
||||
$real_file = realpath( wp_normalize_path( $file ) );
|
||||
$real_directory = realpath( wp_normalize_path( $directory ) );
|
||||
}
|
||||
|
||||
if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) {
|
||||
if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.2-beta2-45176';
|
||||
$wp_version = '5.2-beta2-45177';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user