Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support beta/rc releases #260

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -114,7 +114,7 @@ Subsequent uses of command will use the local cache if it still exists.
Select which language you want to download.

[--version=<version>]
Select which version you want to download. Accepts a version number, 'latest' or 'nightly'.
Select which version you want to download. Accepts a version number, 'latest', 'beta', 'rc', or 'nightly'.

[--skip-content]
Download WP without the default themes and plugins.
Expand Down Expand Up @@ -359,7 +359,7 @@ update isn't actually running.
Only perform updates for minor releases (e.g. update from WP 4.3 to 4.3.3 instead of 4.4.2).

[--version=<version>]
Update to a specific version, instead of to the latest version. Alternatively accepts 'nightly'.
Update to a specific version, instead of to the latest version. Alternatively accepts 'latest', 'beta', 'rc', or 'nightly'.

[--force]
Update even when installed WP version is greater than the requested version.
Expand Down
13 changes: 9 additions & 4 deletions src/Core_Command.php
Expand Up @@ -36,6 +36,8 @@ class Core_Command extends WP_CLI_Command {
* Lists the most recent versions when there are updates available,
* or success message when up to date.
*
* @todo how does this behave with beta/rc/nightly?
*
* ## OPTIONS
*
* [--minor]
Expand Down Expand Up @@ -114,7 +116,7 @@ public function check_update( $_, $assoc_args ) {
* : Select which language you want to download.
*
* [--version=<version>]
* : Select which version you want to download. Accepts a version number, 'latest' or 'nightly'.
* : Select which version you want to download. Accepts a version number, 'latest', 'beta', 'rc', or 'nightly'.
*
* [--skip-content]
* : Download WP without the default themes and plugins.
Expand Down Expand Up @@ -327,9 +329,9 @@ function () use ( $temp ) {
copy( $temp, $download_dir . basename( $temp ) );
}

// Do not use the cache for nightly builds or for downloaded URLs
// Do not use the cache for beta/rc/nightly builds or for downloaded URLs
// (the URL could be something like "latest.zip" or "nightly.zip").
if ( ! $from_url && 'nightly' !== $version ) {
if ( ! $from_url && ! in_array( $version, [ 'beta', 'rc', 'nightly' ], true ) ) {
$cache->import( $cache_key, $temp );
}
}
Expand Down Expand Up @@ -1058,7 +1060,7 @@ private static function get_core_checksums( $version, $locale, $insecure ) {
* : Only perform updates for minor releases (e.g. update from WP 4.3 to 4.3.3 instead of 4.4.2).
*
* [--version=<version>]
* : Update to a specific version, instead of to the latest version. Alternatively accepts 'nightly'.
* : Update to a specific version, instead of to the latest version. Alternatively accepts 'latest', 'beta', 'rc', or 'nightly'.
*
* [--force]
* : Update even when installed WP version is greater than the requested version.
Expand Down Expand Up @@ -1149,6 +1151,8 @@ public function update( $args, $assoc_args ) {
list( $update ) = $from_api->updates;
}
} elseif ( Utils\wp_version_compare( $assoc_args['version'], '<' )
|| 'beta' === $assoc_args['version']
|| 'rc' === $assoc_args['version']
|| 'nightly' === $assoc_args['version']
Comment on lines +1154 to 1156
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use in_array here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep could do. I try to touch as few lines as possible, at least to begin with.

|| Utils\get_flag_value( $assoc_args, 'force' ) ) {

Expand Down Expand Up @@ -1338,6 +1342,7 @@ public function update_db( $args, $assoc_args ) {
* @return string
*/
private function get_download_url( $version, $locale = 'en_US', $file_type = 'zip' ) {
// @todo

if ( 'nightly' === $version ) {
if ( 'zip' === $file_type ) {
Expand Down
2 changes: 2 additions & 0 deletions src/WP_CLI/Core/CoreUpgrader.php
Expand Up @@ -93,6 +93,7 @@ function () use ( $temp ) {
$cache_key = "core/{$filename}-{$update->locale}.{$extension}";
$cache_file = $cache->has( $cache_key );

// @todo
if ( $cache_file && false === stripos( $package, 'https://wordpress.org/nightly-builds/' )
&& false === stripos( $package, 'http://wordpress.org/nightly-builds/' ) ) {
WP_CLI::log( "Using cached file '{$cache_file}'..." );
Expand Down Expand Up @@ -125,6 +126,7 @@ function () use ( $temp ) {
return new WP_Error( 'download_failed', $this->strings['download_failed'] );
}

// @todo
if ( false === stripos( $package, 'https://wordpress.org/nightly-builds/' ) ) {
$cache->import( $cache_key, $temp );
}
Expand Down