From 2d9f3957ce59e526112fd529a6c2365585ca45d4 Mon Sep 17 00:00:00 2001 From: Isla Waters Date: Tue, 17 Dec 2024 21:42:38 -0500 Subject: [PATCH 1/2] Allow installing major version with trailing zero Fixes #275 --- features/core-download.feature | 12 +++++++++++- features/core-update.feature | 11 +++++++++++ src/Core_Command.php | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) 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..0447a706 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1349,6 +1349,9 @@ 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}"; + if ( substr( $version, -2 ) === '.0' ) { + $version = substr( $version, 0, -2 ); + } return "https://{$locale_subdomain}wordpress.org/wordpress-{$version}{$locale_suffix}.{$file_type}"; } From 4b1d5f6a291ef0045fbe7110e21621c76508e192 Mon Sep 17 00:00:00 2001 From: Isla Waters Date: Tue, 17 Dec 2024 22:19:35 -0500 Subject: [PATCH 2/2] Require more than one . So we still support normal .0 releases --- src/Core_Command.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 0447a706..5bee2550 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -1349,7 +1349,8 @@ 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}"; - if ( substr( $version, -2 ) === '.0' ) { + // Match 6.7.0 but not 6.0 + if ( substr_count( $version, '.' ) > 1 && substr( $version, -2 ) === '.0' ) { $version = substr( $version, 0, -2 ); }