Skip to content

Commit

Permalink
Merge pull request #276 from mrsdizzie/trailing-zero
Browse files Browse the repository at this point in the history
Allow installing major version with trailing zero
  • Loading branch information
swissspidy authored Dec 18, 2024
2 parents 3bcf32c + 4b1d5f6 commit 4bb39ec
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
12 changes: 11 additions & 1 deletion features/core-download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
"""

11 changes: 11 additions & 0 deletions features/core-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""


4 changes: 4 additions & 0 deletions src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
Expand Down

0 comments on commit 4bb39ec

Please # to comment.