Skip to content

Commit ee02d5b

Browse files
authored
WP_HTTP: Fallback for existing filename in streaming mode already exists.
This only is for the case of `stream => true` without a specified filename to stream to, in that case, it's expected that a temporary file path would be returned.
1 parent 6680408 commit ee02d5b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/wp-includes/class-wp-http.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ public function request( $url, $args = array() ) {
310310
if ( $parsed_args['stream'] ) {
311311
if ( empty( $parsed_args['filename'] ) ) {
312312
$parsed_args['filename'] = get_temp_dir() . basename( $url );
313+
314+
// If that file exists, fallback to a temporary file.
315+
if ( file_exists( $parsed_args['filename'] ) ) {
316+
$parsed_args['filename'] = wp_tempnam( basename( $url ) );
317+
}
313318
}
314319

315320
// Force some settings if we are streaming to a file and check for existence

0 commit comments

Comments
 (0)