From 3605980a752a80c100b8398a8bcb4f4a93deec0a Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sat, 31 Oct 2026 01:06:48 +0100 Subject: [PATCH 1/3] Name the archive of core download --no-extract after the release A freshly downloaded archive was saved under the name of the temporary download file, while one taken from the cache got the release name. Use the release name in both cases, and the name from the URL for URL downloads. Make the scenario covering this start from an empty cache, so that it no longer depends on the scenario before it having filled the cache. Co-Authored-By: Claude Opus 5.5 --- features/core-download.feature | 1 + src/Core_Command.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/features/core-download.feature b/features/core-download.feature index 154eb897..a61e1ea0 100644 --- a/features/core-download.feature +++ b/features/core-download.feature @@ -523,6 +523,7 @@ Feature: Download WordPress Scenario: Core download with no-extract should not unzip the download file Given an empty directory + And an empty cache When I run `wp core download --version=4.5 --locale=de_DE --no-extract` Then the wp-content directory should not exist diff --git a/src/Core_Command.php b/src/Core_Command.php index 33d0bc04..51cea802 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -414,7 +414,12 @@ function () use ( $old_temp ) { WP_CLI::error( "Couldn't extract WordPress archive. {$exception->getMessage()}" ); } } else { - copy( $temp, $download_dir . basename( $temp ) ); + // Name the archive like the cached one, rather than after the temporary file. + $archive_name = $from_url ? basename( (string) Utils\parse_url( $download_url, PHP_URL_PATH ) ) : "wordpress-{$version}-{$locale}.{$extension}"; + if ( '' === $archive_name || '.' === $archive_name ) { + $archive_name = basename( $temp ); + } + copy( $temp, $download_dir . $archive_name ); } // Do not use the cache for nightly builds or for downloaded URLs From 263ed7f3acc95488630043d6f34299af8e9a4c51 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sat, 31 Oct 2026 01:14:48 +0100 Subject: [PATCH 2/3] Report when the archive cannot be copied to the destination Co-Authored-By: Claude Opus 5.5 --- src/Core_Command.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 51cea802..81eebfc7 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -292,8 +292,8 @@ public function download( $args, $assoc_args ) { WP_CLI::warning( 'Extraction failed, downloading a new copy...' ); $bad_cache = true; } - } else { - copy( $cache_file, $download_dir . basename( $cache_file ) ); + } elseif ( ! copy( $cache_file, $download_dir . basename( $cache_file ) ) ) { + WP_CLI::error( "Couldn't copy WordPress archive to '{$download_dir}" . basename( $cache_file ) . "'." ); } } @@ -419,7 +419,9 @@ function () use ( $old_temp ) { if ( '' === $archive_name || '.' === $archive_name ) { $archive_name = basename( $temp ); } - copy( $temp, $download_dir . $archive_name ); + if ( ! copy( $temp, $download_dir . $archive_name ) ) { + WP_CLI::error( "Couldn't copy WordPress archive to '{$download_dir}{$archive_name}'." ); + } } // Do not use the cache for nightly builds or for downloaded URLs From 2be62f5782c01c8e8d4390c30b50290b993ec0d7 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sat, 31 Oct 2026 01:26:52 +0100 Subject: [PATCH 3/3] Cover failing to save the archive with a scenario Co-Authored-By: Claude Opus 5.5 --- features/core-download.feature | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/features/core-download.feature b/features/core-download.feature index a61e1ea0..1242fc80 100644 --- a/features/core-download.feature +++ b/features/core-download.feature @@ -529,6 +529,29 @@ Feature: Download WordPress Then the wp-content directory should not exist And the wordpress-4.5-de_DE.zip file should exist + Scenario: Core download with no-extract reports when the archive cannot be saved + Given an empty directory + And an empty cache + And a wordpress-4.5-de_DE.zip/placeholder.txt file: + """ + A directory in the way of the archive. + """ + + When I try `wp core download --version=4.5 --locale=de_DE --no-extract` + Then STDERR should contain: + """ + Error: Couldn't copy WordPress archive to + """ + And the return code should be 1 + + When I run `wp core download --version=4.5 --locale=de_DE --no-extract --path=other` + And I try `wp core download --version=4.5 --locale=de_DE --no-extract` + Then STDERR should contain: + """ + Error: Couldn't copy WordPress archive to + """ + And the return code should be 1 + Scenario: Core download with no-extract should not unzip the download file (already cached) Given an empty directory