Skip to content

Commit b3d2b5d

Browse files
Copilotschlessera
andauthored
Replace manual temp path construction with Utils\make_temp_file() (#346)
Co-authored-by: schlessera <83631+schlessera@users.noreply.github.com>
1 parent d4c4175 commit b3d2b5d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/Core_Command.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function download( $args, $assoc_args ) {
298298
}
299299

300300
if ( ! $cache_file || $bad_cache ) {
301-
$temp = Utils\get_temp_dir() . uniqid( 'wp_' ) . '.tmp';
301+
$temp = Utils\make_temp_file( 'wp_', '.tmp' );
302302
register_shutdown_function(
303303
function () use ( &$temp ) {
304304
if ( file_exists( $temp ) ) {
@@ -2242,7 +2242,7 @@ private function remove_directory( $dir, $abspath_realpath_trailing ) {
22422242
}
22432243

22442244
private static function strip_content_dir( $zip_file ) {
2245-
$new_zip_file = Utils\get_temp_dir() . uniqid( 'wp_' ) . '.zip';
2245+
$new_zip_file = Utils\make_temp_file( 'wp_', '.zip' );
22462246
register_shutdown_function(
22472247
function () use ( $new_zip_file ) {
22482248
if ( file_exists( $new_zip_file ) ) {

‎src/WP_CLI/Core/CoreUpgrader.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function download_package( $package, $check_signatures = false, $hook_ext
8484
$filename = pathinfo( $package, PATHINFO_FILENAME );
8585
$extension = pathinfo( $package, PATHINFO_EXTENSION );
8686

87-
$temp = Utils\get_temp_dir() . uniqid( 'wp_' ) . ".{$extension}";
87+
$temp = Utils\make_temp_file( 'wp_', ".{$extension}" );
8888
register_shutdown_function(
8989
function () use ( $temp ) {
9090
if ( file_exists( $temp ) ) {

0 commit comments

Comments
 (0)