Media: In `wp_unique_filename()`, use explicit type casting when incrementing `$number`.
This prevents the "non-numeric value encountered" warning in PHP 7.1, caused by trying to increment an empty string on the first loop iteration. Props drrobotnik for initial patch. Fixes #39774. Built from https://develop.svn.wordpress.org/trunk@40039 git-svn-id: http://core.svn.wordpress.org/trunk@39976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e0e9568e24
commit
8f855f46b0
|
@ -2063,7 +2063,7 @@ 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;
|
||||
$new_number = (int) $number + 1;
|
||||
$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;
|
||||
|
@ -2083,11 +2083,13 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
|
|||
}
|
||||
|
||||
while ( file_exists( $dir . "/$filename" ) ) {
|
||||
$new_number = (int) $number + 1;
|
||||
if ( '' == "$number$ext" ) {
|
||||
$filename = "$filename-" . ++$number;
|
||||
$filename = "$filename-" . $new_number;
|
||||
} else {
|
||||
$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . ++$number . $ext, $filename );
|
||||
$filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . $new_number . $ext, $filename );
|
||||
}
|
||||
$number = $new_number;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-40038';
|
||||
$wp_version = '4.8-alpha-40039';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue