Skip to content

Always use ZIP archives#333

Open
swissspidy wants to merge 4 commits into
mainfrom
fix/no-tar
Open

Always use ZIP archives#333
swissspidy wants to merge 4 commits into
mainfrom
fix/no-tar

Conversation

@swissspidy
Copy link
Copy Markdown
Member

@swissspidy swissspidy commented May 22, 2026

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

@github-actions github-actions Bot added command:core-download Related to 'core download' command scope:distribution Related to distribution labels May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy added this to the 2.1.30 milestone May 23, 2026
@swissspidy swissspidy marked this pull request as ready for review May 23, 2026 08:25
@swissspidy swissspidy requested a review from a team as a code owner May 23, 2026 08:26
Copilot AI review requested due to automatic review settings May 23, 2026 08:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .zip URLs and cache keys consistently.
  • Simplify get_download_url() to always return ZIP download URLs.
  • Update Behat feature specs to expect .zip artifacts 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 download will require the PHP Zip extension (ZipArchive) for the default --extract path in all cases. Previously, non-nightly/non-skip-content downloads could extract .tar.gz without ZipArchive, so this is a behavior/compatibility change for environments where ZipArchive isn't installed. Consider adding a fallback (e.g., keep .tar.gz when 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.

Comment thread src/Core_Command.php Outdated
Comment thread src/Core_Command.php Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.gz URL). With --no-extract, the downloaded file will be copied out as wp_*.zip regardless 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_url path.
		$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 ) ) {

Comment thread src/Core_Command.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:core-download Related to 'core download' command scope:distribution Related to distribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download should stick to zip for better cacheability

2 participants