Filesystem: Use a more unique filename in `wp_tempnam()` and `get_filesystem_method()`.
Using a filename which was generated from `time()` could cause two processes to try to use the same filename, causing unexpected behaviour. Props jrchamp, bikecrazyy. Fixes #42265. Built from https://develop.svn.wordpress.org/trunk@42224 git-svn-id: http://core.svn.wordpress.org/trunk@42053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e0b4933fdb
commit
4073743527
|
@ -624,7 +624,7 @@ function wp_tempnam( $filename = '', $dir = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) {
|
if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) {
|
||||||
$filename = time();
|
$filename = uniqid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the basename of the given file without the extension as the name for the temporary directory
|
// Use the basename of the given file without the extension as the name for the temporary directory
|
||||||
|
@ -1466,7 +1466,7 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
|
||||||
|
|
||||||
if ( ! $method ) {
|
if ( ! $method ) {
|
||||||
|
|
||||||
$temp_file_name = $context . 'temp-write-test-' . time();
|
$temp_file_name = $context . 'temp-write-test-' . str_replace( '.', '-', uniqid( '', true ) );
|
||||||
$temp_handle = @fopen($temp_file_name, 'w');
|
$temp_handle = @fopen($temp_file_name, 'w');
|
||||||
if ( $temp_handle ) {
|
if ( $temp_handle ) {
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-42222';
|
$wp_version = '5.0-alpha-42224';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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