- Fix PHP warnings in `wp_unique_filename()` when the destination directory is unreadable.
- Run the final name collision test only for files that are saved to the uploads directory.
- Update the unit tests to match.

Props eden159, audrasjb, azaozz.
Merges [46965] to the 5.3 branch.
Fixes #48960.
Built from https://develop.svn.wordpress.org/branches/5.3@46979


git-svn-id: http://core.svn.wordpress.org/branches/5.3@46779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2019-12-17 21:12:03 +00:00
parent 7b21983b01
commit fd030a496f
2 changed files with 10 additions and 4 deletions

View File

@ -2472,11 +2472,17 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
// Prevent collisions with existing file names that contain dimension-like strings
// (whether they are subsizes or originals uploaded prior to #42437).
$upload_dir = wp_get_upload_dir();
// The (resized) image files would have name and extension, and will be in the uploads dir.
if ( @is_dir( $dir ) && $name && $ext ) {
// List of all files and directories contained in $dir (with the "dot" files removed).
$files = array_diff( scandir( $dir ), array( '.', '..' ) );
if ( $name && $ext && @is_dir( $dir ) && false !== strpos( $dir, $upload_dir['basedir'] ) ) {
// List of all files and directories contained in $dir.
$files = @scandir( $dir );
if ( ! empty( $files ) ) {
// Remove "dot" dirs.
$files = array_diff( $files, array( '.', '..' ) );
}
if ( ! empty( $files ) ) {
while ( _wp_check_existing_file_names( $filename, $files ) ) {

View File

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