mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 07:07:38 +02:00
Upload:
- 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:
parent
7b21983b01
commit
fd030a496f
@ -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
|
// Prevent collisions with existing file names that contain dimension-like strings
|
||||||
// (whether they are subsizes or originals uploaded prior to #42437).
|
// (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.
|
// The (resized) image files would have name and extension, and will be in the uploads dir.
|
||||||
if ( @is_dir( $dir ) && $name && $ext ) {
|
if ( $name && $ext && @is_dir( $dir ) && false !== strpos( $dir, $upload_dir['basedir'] ) ) {
|
||||||
// List of all files and directories contained in $dir (with the "dot" files removed).
|
// List of all files and directories contained in $dir.
|
||||||
$files = array_diff( scandir( $dir ), array( '.', '..' ) );
|
$files = @scandir( $dir );
|
||||||
|
|
||||||
|
if ( ! empty( $files ) ) {
|
||||||
|
// Remove "dot" dirs.
|
||||||
|
$files = array_diff( $files, array( '.', '..' ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! empty( $files ) ) {
|
if ( ! empty( $files ) ) {
|
||||||
while ( _wp_check_existing_file_names( $filename, $files ) ) {
|
while ( _wp_check_existing_file_names( $filename, $files ) ) {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user