Skip to content

Commit 9d6ebb4

Browse files
Add --force-check flag to check-update command (#246)
* Add --force-check flag * Regenerate README * Tweak argument a little bit --------- Co-authored-by: Daniel Bachhuber <[email protected]>
1 parent 91b4e0c commit 9d6ebb4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ wp core
4242
Checks for WordPress updates via Version Check API.
4343

4444
~~~
45-
wp core check-update [--minor] [--major] [--field=<field>] [--fields=<fields>] [--format=<format>]
45+
wp core check-update [--minor] [--major] [--force-check] [--field=<field>] [--fields=<fields>] [--format=<format>]
4646
~~~
4747

4848
Lists the most recent versions when there are updates available,
@@ -56,6 +56,9 @@ or success message when up to date.
5656
[--major]
5757
Compare only the first part of the version number.
5858

59+
[--force-check]
60+
Bypass the transient cache and force a fresh update check.
61+
5962
[--field=<field>]
6063
Prints the value of a single field for each update.
6164

src/Core_Command.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class Core_Command extends WP_CLI_Command {
4444
* [--major]
4545
* : Compare only the first part of the version number.
4646
*
47+
* [--force-check]
48+
* : Bypass the transient cache and force a fresh update check.
49+
*
4750
* [--field=<field>]
4851
* : Prints the value of a single field for each update.
4952
*
@@ -1145,7 +1148,7 @@ public function update( $args, $assoc_args ) {
11451148
return;
11461149
}
11471150
} elseif ( ! empty( $from_api->updates ) ) {
1148-
list( $update ) = $from_api->updates;
1151+
list( $update ) = $from_api->updates;
11491152
}
11501153
} elseif ( Utils\wp_version_compare( $assoc_args['version'], '<' )
11511154
|| 'nightly' === $assoc_args['version']
@@ -1175,7 +1178,7 @@ public function update( $args, $assoc_args ) {
11751178

11761179
if ( ! empty( $update )
11771180
&& ( $update->version !== $wp_version
1178-
|| Utils\get_flag_value( $assoc_args, 'force' ) ) ) {
1181+
|| Utils\get_flag_value( $assoc_args, 'force' ) ) ) {
11791182

11801183
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
11811184

@@ -1354,7 +1357,8 @@ private function get_download_url( $version, $locale = 'en_US', $file_type = 'zi
13541357
* Returns update information.
13551358
*/
13561359
private function get_updates( $assoc_args ) {
1357-
wp_version_check();
1360+
$force_check = Utils\get_flag_value( $assoc_args, 'force-check' );
1361+
wp_version_check( [], $force_check );
13581362
$from_api = get_site_transient( 'update_core' );
13591363
if ( ! $from_api ) {
13601364
return [];

0 commit comments

Comments
 (0)