Always use ZIP archives#333
Open
swissspidy wants to merge 4 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes core download behavior to always use ZIP archives (instead of sometimes using .tar.gz) as an alternative fix for wp-cli/wp-cli#6320, and updates Behat expectations accordingly.
Changes:
- Force WordPress core downloads to use
.zipURLs and cache keys consistently. - Simplify
get_download_url()to always return ZIP download URLs. - Update Behat feature specs to expect
.zipartifacts and updated MD5 outputs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Core_Command.php |
Removes .tar.gz selection logic and makes download URL generation always return .zip. |
features/core-update.feature |
Updates cached core archive expectations from .tar.gz to .zip. |
features/core-install.feature |
Updates localized cached archive expectation to .zip. |
features/core-download.feature |
Updates cache filename expectations and MD5 outputs for ZIP downloads. |
Comments suppressed due to low confidence (1)
src/Core_Command.php:276
- With ZIP now being the only archive type,
wp core downloadwill require the PHP Zip extension (ZipArchive) for the default--extractpath in all cases. Previously, non-nightly/non-skip-content downloads could extract.tar.gzwithout ZipArchive, so this is a behavior/compatibility change for environments whereZipArchiveisn't installed. Consider adding a fallback (e.g., keep.tar.gzwhen ZipArchive is unavailable, or provide an alternate extraction path) or explicitly documenting this new requirement.
$extension = 'zip';
if ( $extract && ! class_exists( 'ZipArchive' ) ) {
WP_CLI::error( 'Extracting a zip file requires ZipArchive.' );
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Extractor class does that for us already
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Core_Command.php:303
- Hard-coding
$extension = 'zip'breaks URL downloads that point to non-zip archives (the PR description notes users may still provide a.tar.gzURL). With--no-extract, the downloaded file will be copied out aswp_*.zipregardless of the actual URL/file type, and extraction may also mis-handle the archive if downstream logic uses the extension. Consider deriving the extension from$download_url(including.tar.gz) or from response headers, at least in the$from_urlpath.
$extension = 'zip';
$cache = WP_CLI::get_cache();
if ( $from_url ) {
$cache_file = null;
} else {
$cache_key = "core/wordpress-{$version}-{$locale}.{$extension}";
$cache_file = $cache->has( $cache_key );
}
$bad_cache = false;
if ( is_string( $cache_file ) ) {
WP_CLI::log( "Using cached file '{$cache_file}'..." );
$skip_content_cache_file = $skip_content ? self::strip_content_dir( $cache_file ) : null;
if ( $extract ) {
try {
Extractor::extract( $skip_content_cache_file ?: $cache_file, $download_dir );
} catch ( Exception $exception ) {
WP_CLI::warning( 'Extraction failed, downloading a new copy...' );
$bad_cache = true;
}
} else {
copy( $cache_file, $download_dir . basename( $cache_file ) );
}
}
if ( ! $cache_file || $bad_cache ) {
$temp = Utils\get_temp_dir() . uniqid( 'wp_' ) . ".{$extension}";
register_shutdown_function(
function () use ( $temp ) {
if ( file_exists( $temp ) ) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative approach for addressing wp-cli/wp-cli#6320, at least partially (one can still manually specify a tar.gz URL).
I tried to find why tar was added in favor of zip and it appears it was done in wp-cli/wp-cli@0723df1 because of this comment: wp-cli/wp-cli#144 (comment)
So not really something that's applicable anymore nowadays.
Fixes #67