diff --git a/features/core-download.feature b/features/core-download.feature index d7af5f3c..624130d7 100644 --- a/features/core-download.feature +++ b/features/core-download.feature @@ -54,7 +54,7 @@ Feature: Download WordPress Scenario: Catch download of non-existent WP version Given an empty directory - When I try `wp core download --version=4.1.0 --force` + When I try `wp core download --version=1.0.3 --force` Then STDERR should contain: """ Error: Release not found. @@ -473,3 +473,13 @@ Feature: Download WordPress Error: Cannot use both --skip-content and --no-extract at the same time. """ And the return code should be 1 + + Scenario: Allow installing major version with trailing zero + Given an empty directory + + When I run `wp core download --version=6.7.0` + Then STDOUT should contain: + """ + Success: + """ + diff --git a/features/core-update.feature b/features/core-update.feature index 9cd7f689..77824dcb 100644 --- a/features/core-update.feature +++ b/features/core-update.feature @@ -347,3 +347,14 @@ Feature: Update WordPress core """ Using cached """ + + Scenario: Allow installing major version with trailing zero + Given a WP install + + When I run `wp core update --version=6.2.0 --force` + Then STDOUT should contain: + """ + Success: + """ + + diff --git a/src/Core_Command.php b/src/Core_Command.php index fbc3edf9..5bee2550 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1349,6 +1349,10 @@ private function get_download_url( $version, $locale = 'en_US', $file_type = 'zi $locale_subdomain = 'en_US' === $locale ? '' : substr( $locale, 0, 2 ) . '.'; $locale_suffix = 'en_US' === $locale ? '' : "-{$locale}"; + // Match 6.7.0 but not 6.0 + if ( substr_count( $version, '.' ) > 1 && substr( $version, -2 ) === '.0' ) { + $version = substr( $version, 0, -2 ); + } return "https://{$locale_subdomain}wordpress.org/wordpress-{$version}{$locale_suffix}.{$file_type}"; }