Skip to content

Commit 69cbc4b

Browse files
authored
Merge pull request #508 from wp-cli/copilot/fix-skip-update-check-issue
2 parents a93ef03 + f956ce1 commit 69cbc4b

10 files changed

+104
-49
lines changed

extension-command.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,33 @@
2222
WP_CLI::add_command( 'theme', 'Theme_Command' );
2323
WP_CLI::add_command( 'theme auto-updates', 'Theme_AutoUpdates_Command', $wpcli_extension_requires_wp_5_5 );
2424
WP_CLI::add_command( 'theme mod', 'Theme_Mod_Command' );
25+
26+
// In admin context, WordPress hooks wp_update_plugins/wp_update_themes to
27+
// various actions, causing update checks to run even when --skip-update-check is passed.
28+
29+
WP_CLI::add_hook(
30+
'before_wp_load',
31+
static function () {
32+
if ( ! \WP_CLI\Utils\get_flag_value( WP_CLI::get_runner()->assoc_args, 'skip-update-check' ) ) {
33+
return;
34+
}
35+
36+
WP_CLI::add_wp_hook(
37+
'wp_loaded',
38+
static function () {
39+
remove_action( 'load-plugins.php', 'wp_update_plugins' );
40+
remove_action( 'load-update.php', 'wp_update_plugins' );
41+
remove_action( 'load-update-core.php', 'wp_update_plugins' );
42+
remove_action( 'admin_init', '_maybe_update_plugins' );
43+
remove_action( 'wp_update_plugins', 'wp_update_plugins' );
44+
45+
remove_action( 'load-themes.php', 'wp_update_themes' );
46+
remove_action( 'load-update.php', 'wp_update_themes' );
47+
remove_action( 'load-update-core.php', 'wp_update_themes' );
48+
remove_action( 'admin_init', '_maybe_update_themes' );
49+
remove_action( 'wp_update_themes', 'wp_update_themes' );
50+
},
51+
PHP_INT_MIN
52+
);
53+
}
54+
);

features/plugin-auto-updates-disable.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Disable auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
5+
And I run `wp plugin install debug-bar https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66
And I run `wp plugin auto-updates enable --all`
77

88
@require-wp-5.5
@@ -25,7 +25,7 @@ Feature: Disable auto-updates for WordPress plugins
2525

2626
@require-wp-5.5
2727
Scenario: Disable auto-updates for multiple plugins
28-
When I run `wp plugin auto-updates disable sample-plugin duplicate-post`
28+
When I run `wp plugin auto-updates disable sample-plugin debug-bar`
2929
Then STDOUT should be:
3030
"""
3131
Success: Disabled 2 of 2 plugin auto-updates.
@@ -73,7 +73,7 @@ Feature: Disable auto-updates for WordPress plugins
7373
@require-wp-5.5
7474
Scenario: Filter when disabling auto-updates for already disabled selection of plugins
7575
When I run `wp plugin auto-updates disable sample-plugin`
76-
And I run `wp plugin auto-updates disable sample-plugin duplicate-post --enabled-only`
76+
And I run `wp plugin auto-updates disable sample-plugin debug-bar --enabled-only`
7777
Then STDOUT should be:
7878
"""
7979
Success: Disabled 1 of 1 plugin auto-updates.

features/plugin-auto-updates-enable.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Enable auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
5+
And I run `wp plugin install debug-bar https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66

77
@require-wp-5.5
88
Scenario: Show an error if required params are missing
@@ -24,7 +24,7 @@ Feature: Enable auto-updates for WordPress plugins
2424

2525
@require-wp-5.5
2626
Scenario: Enable auto-updates for multiple plugins
27-
When I run `wp plugin auto-updates enable sample-plugin duplicate-post`
27+
When I run `wp plugin auto-updates enable sample-plugin debug-bar`
2828
Then STDOUT should be:
2929
"""
3030
Success: Enabled 2 of 2 plugin auto-updates.
@@ -72,7 +72,7 @@ Feature: Enable auto-updates for WordPress plugins
7272
@require-wp-5.5
7373
Scenario: Filter when enabling auto-updates for already enabled selection of plugins
7474
When I run `wp plugin auto-updates enable sample-plugin`
75-
And I run `wp plugin auto-updates enable sample-plugin duplicate-post --disabled-only`
75+
And I run `wp plugin auto-updates enable sample-plugin debug-bar --disabled-only`
7676
Then STDOUT should be:
7777
"""
7878
Success: Enabled 1 of 1 plugin auto-updates.

features/plugin-auto-updates-status.feature

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Show the status of auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
5+
And I run `wp plugin install debug-bar https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66

77
@require-wp-5.5
88
Scenario: Show an error if required params are missing
@@ -23,10 +23,10 @@ Feature: Show the status of auto-updates for WordPress plugins
2323

2424
@require-wp-5.5
2525
Scenario: Show the status of auto-updates multiple plugins
26-
When I run `wp plugin auto-updates status duplicate-post sample-plugin`
26+
When I run `wp plugin auto-updates status debug-bar sample-plugin`
2727
Then STDOUT should be a table containing rows:
2828
| name | status |
29-
| duplicate-post | disabled |
29+
| debug-bar | disabled |
3030
| sample-plugin | disabled |
3131
And the return code should be 0
3232

@@ -36,7 +36,7 @@ Feature: Show the status of auto-updates for WordPress plugins
3636
Then STDOUT should be a table containing rows:
3737
| name | status |
3838
| akismet | disabled |
39-
| duplicate-post | disabled |
39+
| debug-bar | disabled |
4040
| sample-plugin | disabled |
4141
And the return code should be 0
4242

@@ -45,7 +45,7 @@ Feature: Show the status of auto-updates for WordPress plugins
4545
Then STDOUT should be a table containing rows:
4646
| name | status |
4747
| akismet | enabled |
48-
| duplicate-post | enabled |
48+
| debug-bar | enabled |
4949
| sample-plugin | enabled |
5050
And the return code should be 0
5151

@@ -57,7 +57,7 @@ Feature: Show the status of auto-updates for WordPress plugins
5757
Then STDOUT should be a table containing rows:
5858
| name | status |
5959
| akismet | disabled |
60-
| duplicate-post | disabled |
60+
| debug-bar | disabled |
6161
| sample-plugin | enabled |
6262
And the return code should be 0
6363

@@ -71,7 +71,7 @@ Feature: Show the status of auto-updates for WordPress plugins
7171
Then STDOUT should be a table containing rows:
7272
| name | status |
7373
| akismet | disabled |
74-
| duplicate-post | disabled |
74+
| debug-bar | disabled |
7575
And the return code should be 0
7676

7777
When I try `wp plugin auto-updates status --all --enabled-only --disabled-only`
@@ -92,7 +92,7 @@ Feature: Show the status of auto-updates for WordPress plugins
9292
"""
9393
And STDOUT should contain:
9494
"""
95-
duplicate-post
95+
debug-bar
9696
"""
9797

9898
When I run `wp plugin auto-updates status sample-plugin --field=status`
@@ -114,7 +114,7 @@ Feature: Show the status of auto-updates for WordPress plugins
114114
"""
115115
And STDOUT should contain:
116116
"""
117-
{"name":"duplicate-post","status":"disabled"}
117+
{"name":"debug-bar","status":"disabled"}
118118
"""
119119

120120
When I run `wp plugin auto-updates status --all --format=csv`
@@ -128,7 +128,7 @@ Feature: Show the status of auto-updates for WordPress plugins
128128
"""
129129
And STDOUT should contain:
130130
"""
131-
duplicate-post,disabled
131+
debug-bar,disabled
132132
"""
133133

134134
@require-wp-5.5

features/plugin-dependencies.feature

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Feature: Plugin dependencies support
6161
<?php
6262
/**
6363
* Plugin Name: Test Plugin
64-
* Requires Plugins: duplicate-post, debug-bar
64+
* Requires Plugins: debug-bar, disable-embeds
6565
*/
6666
"""
6767

@@ -75,13 +75,13 @@ Feature: Plugin dependencies support
7575
Success:
7676
"""
7777

78-
When I run `wp plugin list --name=duplicate-post --field=status`
78+
When I run `wp plugin list --name=debug-bar --field=status`
7979
Then STDOUT should be:
8080
"""
8181
inactive
8282
"""
8383

84-
When I run `wp plugin list --name=debug-bar --field=status`
84+
When I run `wp plugin list --name=disable-embeds --field=status`
8585
Then STDOUT should be:
8686
"""
8787
inactive
@@ -119,7 +119,8 @@ Feature: Plugin dependencies support
119119
Warning: akismet: Plugin already installed.
120120
"""
121121

122-
When I run `wp plugin list --fields=name,status --format=csv`
122+
# Expecting a warning for BuddyPress attempting a redirect upon activation.
123+
When I try `wp plugin list --fields=name,status --format=csv`
123124
Then STDOUT should contain:
124125
"""
125126
buddypress,active

features/plugin-install.feature

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ Feature: Install WordPress plugins
323323
"""
324324
Warning: Plugin already installed.
325325
"""
326+
And STDERR should not contain:
327+
"""
328+
plugin could not be found
329+
"""
326330
And STDOUT should contain:
327331
"""
328332
Success: Plugin already installed.
@@ -371,14 +375,14 @@ Feature: Install WordPress plugins
371375
Scenario: Install plugin using WordPress.org directory URL
372376
Given a WP install
373377

374-
When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/`
378+
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/`
375379
Then STDOUT should contain:
376380
"""
377-
Detected WordPress.org plugins directory URL, using slug: hello-dolly
381+
Detected WordPress.org plugins directory URL, using slug: debug-bar
378382
"""
379383
And the return code should be 0
380384

381-
When I run `wp plugin list --name=hello-dolly --field=status`
385+
When I run `wp plugin list --name=debug-bar --field=status`
382386
Then STDOUT should be:
383387
"""
384388
inactive
@@ -387,14 +391,14 @@ Feature: Install WordPress plugins
387391
Scenario: Install and activate plugin using WordPress.org directory URL
388392
Given a WP install
389393

390-
When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/ --activate`
394+
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/ --activate`
391395
Then STDOUT should contain:
392396
"""
393-
Detected WordPress.org plugins directory URL, using slug: hello-dolly
397+
Detected WordPress.org plugins directory URL, using slug: debug-bar
394398
"""
395399
And the return code should be 0
396400

397-
When I run `wp plugin list --name=hello-dolly --field=status`
401+
When I run `wp plugin list --name=debug-bar --field=status`
398402
Then STDOUT should be:
399403
"""
400404
active
@@ -403,35 +407,35 @@ Feature: Install WordPress plugins
403407
Scenario: Install with --activate on already-active plugin should keep it activated
404408
Given a WP install
405409

406-
When I run `wp plugin install hello-dolly --activate`
410+
When I run `wp plugin install debug-bar --activate`
407411
Then STDOUT should contain:
408412
"""
409-
Plugin 'hello-dolly' activated.
413+
Plugin 'debug-bar' activated.
410414
"""
411415
And the return code should be 0
412416

413-
When I run `wp plugin list --name=hello-dolly --field=status`
417+
When I run `wp plugin list --name=debug-bar --field=status`
414418
Then STDOUT should be:
415419
"""
416420
active
417421
"""
418422

419-
When I try `wp plugin install hello-dolly --activate`
423+
When I try `wp plugin install debug-bar --activate`
420424
Then STDERR should contain:
421425
"""
422-
Warning: hello-dolly: Plugin already installed.
426+
Warning: debug-bar: Plugin already installed.
423427
"""
424428
And STDOUT should contain:
425429
"""
426-
Activating 'hello-dolly'...
430+
Activating 'debug-bar'...
427431
"""
428432
And STDOUT should contain:
429433
"""
430-
Plugin 'hello-dolly' activated.
434+
Plugin 'debug-bar' activated.
431435
"""
432436
And the return code should be 0
433437

434-
When I run `wp plugin list --name=hello-dolly --field=status`
438+
When I run `wp plugin list --name=debug-bar --field=status`
435439
Then STDOUT should be:
436440
"""
437441
active
@@ -440,35 +444,35 @@ Feature: Install WordPress plugins
440444
Scenario: Install with --activate-network on already-network-active plugin should keep it activated
441445
Given a WP multisite install
442446

443-
When I run `wp plugin install hello-dolly --activate-network`
447+
When I run `wp plugin install debug-bar --activate-network`
444448
Then STDOUT should contain:
445449
"""
446-
Plugin 'hello-dolly' network activated.
450+
Plugin 'debug-bar' network activated.
447451
"""
448452
And the return code should be 0
449453

450-
When I run `wp plugin list --name=hello-dolly --field=status`
454+
When I run `wp plugin list --name=debug-bar --field=status`
451455
Then STDOUT should be:
452456
"""
453457
active-network
454458
"""
455459

456-
When I try `wp plugin install hello-dolly --activate-network`
460+
When I try `wp plugin install debug-bar --activate-network`
457461
Then STDERR should contain:
458462
"""
459-
Warning: hello-dolly: Plugin already installed.
463+
Warning: debug-bar: Plugin already installed.
460464
"""
461465
And STDOUT should contain:
462466
"""
463-
Network-activating 'hello-dolly'...
467+
Network-activating 'debug-bar'...
464468
"""
465469
And STDOUT should contain:
466470
"""
467-
Plugin 'hello-dolly' network activated.
471+
Plugin 'debug-bar' network activated.
468472
"""
469473
And the return code should be 0
470474

471-
When I run `wp plugin list --name=hello-dolly --field=status`
475+
When I run `wp plugin list --name=debug-bar --field=status`
472476
Then STDOUT should be:
473477
"""
474478
active-network

features/plugin-search.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Feature: Search WordPress.org plugins
2222
Scenario: Search for plugins with url field
2323
Given a WP install
2424

25-
When I run `wp plugin search gutenberg --fields=slug,url --format=csv`
25+
When I run `wp plugin search gutenberg --fields=slug,url --format=csv --per-page=20`
2626
Then STDOUT should contain:
2727
"""
2828
gutenberg,https://wordpress.org/plugins/gutenberg/

features/plugin.feature

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,12 @@ Feature: Manage WordPress plugins
428428
Success: Transient deleted.
429429
"""
430430

431-
When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check`
432-
Then STDOUT should be a table containing rows:
431+
When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check --debug=http`
432+
Then STDERR should not contain:
433+
"""
434+
HTTP POST request to https://api.wordpress.org/plugins/update-check
435+
"""
436+
And STDOUT should be a table containing rows:
433437
| name | status | update |
434438
| wordpress-importer | inactive | none |
435439

features/theme.feature

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,12 @@ Feature: Manage WordPress themes
228228
Success: Transient deleted.
229229
"""
230230

231-
When I run `wp theme list --fields=name,status,update --skip-update-check`
232-
Then STDOUT should be a table containing rows:
231+
When I run `wp theme list --fields=name,status,update --skip-update-check --debug=http`
232+
Then STDERR should not contain:
233+
"""
234+
HTTP POST request to https://api.wordpress.org/themes/update-check
235+
"""
236+
And STDOUT should be a table containing rows:
233237
| name | status | update |
234238
| astra | inactive | none |
235239

0 commit comments

Comments
 (0)