From f30fe54d6252318bc9c55124ea9913f3f283260d Mon Sep 17 00:00:00 2001 From: Shawn Hooper Date: Fri, 10 Nov 2023 18:31:50 -0500 Subject: [PATCH 1/3] Add --force-check flag --- src/Core_Command.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Core_Command.php b/src/Core_Command.php index 1b82223a..831229c8 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -62,6 +62,9 @@ class Core_Command extends WP_CLI_Command { * - yaml * --- * + * [--force-check] + * : Forces check even if WordPress is up to date. + * * ## EXAMPLES * * $ wp core check-update @@ -1145,7 +1148,7 @@ public function update( $args, $assoc_args ) { return; } } elseif ( ! empty( $from_api->updates ) ) { - list( $update ) = $from_api->updates; + list( $update ) = $from_api->updates; } } elseif ( Utils\wp_version_compare( $assoc_args['version'], '<' ) || 'nightly' === $assoc_args['version'] @@ -1175,7 +1178,7 @@ public function update( $args, $assoc_args ) { if ( ! empty( $update ) && ( $update->version !== $wp_version - || Utils\get_flag_value( $assoc_args, 'force' ) ) ) { + || Utils\get_flag_value( $assoc_args, 'force' ) ) ) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; @@ -1354,7 +1357,8 @@ private function get_download_url( $version, $locale = 'en_US', $file_type = 'zi * Returns update information. */ private function get_updates( $assoc_args ) { - wp_version_check(); + $force_check = Utils\get_flag_value( $assoc_args, 'force-check' ); + wp_version_check( [], $force_check ); $from_api = get_site_transient( 'update_core' ); if ( ! $from_api ) { return []; From bdba21c0100bfaba477f3c66995a26ba6106081f Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 10 Nov 2023 15:43:27 -0800 Subject: [PATCH 2/3] Regenerate README --- README.md | 5 ++++- src/Core_Command.php | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ead932b4..0f11f51d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ wp core Checks for WordPress updates via Version Check API. ~~~ -wp core check-update [--minor] [--major] [--field=] [--fields=] [--format=] +wp core check-update [--minor] [--major] [--force-check] [--field=] [--fields=] [--format=] ~~~ Lists the most recent versions when there are updates available, @@ -56,6 +56,9 @@ or success message when up to date. [--major] Compare only the first part of the version number. + [--force-check] + Forces check even if WordPress is up to date. + [--field=] Prints the value of a single field for each update. diff --git a/src/Core_Command.php b/src/Core_Command.php index 831229c8..bfe2610a 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -44,6 +44,9 @@ class Core_Command extends WP_CLI_Command { * [--major] * : Compare only the first part of the version number. * + * [--force-check] + * : Forces check even if WordPress is up to date. + * * [--field=] * : Prints the value of a single field for each update. * @@ -62,9 +65,6 @@ class Core_Command extends WP_CLI_Command { * - yaml * --- * - * [--force-check] - * : Forces check even if WordPress is up to date. - * * ## EXAMPLES * * $ wp core check-update From 23259b1355904e4d737b1c67c2434fa7ff854cea Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 10 Nov 2023 15:44:31 -0800 Subject: [PATCH 3/3] Tweak argument a little bit --- README.md | 2 +- src/Core_Command.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0f11f51d..a6648c90 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ or success message when up to date. Compare only the first part of the version number. [--force-check] - Forces check even if WordPress is up to date. + Bypass the transient cache and force a fresh update check. [--field=] Prints the value of a single field for each update. diff --git a/src/Core_Command.php b/src/Core_Command.php index bfe2610a..c1dbd2d9 100644 --- a/src/Core_Command.php +++ b/src/Core_Command.php @@ -45,7 +45,7 @@ class Core_Command extends WP_CLI_Command { * : Compare only the first part of the version number. * * [--force-check] - * : Forces check even if WordPress is up to date. + * : Bypass the transient cache and force a fresh update check. * * [--field=] * : Prints the value of a single field for each update.