Skip to content

Commit 4bb39ec

Browse files
authored
Merge pull request #276 from mrsdizzie/trailing-zero
Allow installing major version with trailing zero
2 parents 3bcf32c + 4b1d5f6 commit 4bb39ec

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

features/core-download.feature

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Feature: Download WordPress
5454
Scenario: Catch download of non-existent WP version
5555
Given an empty directory
5656

57-
When I try `wp core download --version=4.1.0 --force`
57+
When I try `wp core download --version=1.0.3 --force`
5858
Then STDERR should contain:
5959
"""
6060
Error: Release not found.
@@ -473,3 +473,13 @@ Feature: Download WordPress
473473
Error: Cannot use both --skip-content and --no-extract at the same time.
474474
"""
475475
And the return code should be 1
476+
477+
Scenario: Allow installing major version with trailing zero
478+
Given an empty directory
479+
480+
When I run `wp core download --version=6.7.0`
481+
Then STDOUT should contain:
482+
"""
483+
Success:
484+
"""
485+

features/core-update.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,14 @@ Feature: Update WordPress core
347347
"""
348348
Using cached
349349
"""
350+
351+
Scenario: Allow installing major version with trailing zero
352+
Given a WP install
353+
354+
When I run `wp core update --version=6.2.0 --force`
355+
Then STDOUT should contain:
356+
"""
357+
Success:
358+
"""
359+
360+

src/Core_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,10 @@ private function get_download_url( $version, $locale = 'en_US', $file_type = 'zi
13491349

13501350
$locale_subdomain = 'en_US' === $locale ? '' : substr( $locale, 0, 2 ) . '.';
13511351
$locale_suffix = 'en_US' === $locale ? '' : "-{$locale}";
1352+
// Match 6.7.0 but not 6.0
1353+
if ( substr_count( $version, '.' ) > 1 && substr( $version, -2 ) === '.0' ) {
1354+
$version = substr( $version, 0, -2 );
1355+
}
13521356

13531357
return "https://{$locale_subdomain}wordpress.org/wordpress-{$version}{$locale_suffix}.{$file_type}";
13541358
}

0 commit comments

Comments
 (0)