Formatting: when making unique filenames in `wp_unique_filename()` by adding an incrementing number, prefix it with a dash to disambiguate from files that end in numbers.
Updates unit tests. Props mikejolley, tyxla. Fixes #21453. Built from https://develop.svn.wordpress.org/trunk@35276 git-svn-id: http://core.svn.wordpress.org/trunk@35242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4f16590e8e
commit
89d1eb1e00
|
@ -1918,18 +1918,19 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
|
|||
// Check for both lower and upper case extension or image sub-sizes may be overwritten.
|
||||
while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
|
||||
$new_number = $number + 1;
|
||||
$filename = str_replace( "$number$ext", "$new_number$ext", $filename );
|
||||
$filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 );
|
||||
$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename );
|
||||
$filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 );
|
||||
$number = $new_number;
|
||||
}
|
||||
return $filename2;
|
||||
}
|
||||
|
||||
while ( file_exists( $dir . "/$filename" ) ) {
|
||||
if ( '' == "$number$ext" )
|
||||
$filename = $filename . ++$number . $ext;
|
||||
else
|
||||
$filename = str_replace( "$number$ext", ++$number . $ext, $filename );
|
||||
if ( '' == "$number$ext" ) {
|
||||
$filename = "$filename-" . ++$number;
|
||||
} else {
|
||||
$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . ++$number . $ext, $filename );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-35275';
|
||||
$wp_version = '4.4-alpha-35276';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue