Skip to content

Commit f37da9c

Browse files
committed
Don't use transient values when doing wp plugin|theme list
This changes the default behavior to always check wordpress.org for the latest information when doing wp plugin|theme list unless the existing `--skip-update-check` flag is passed.
1 parent 33afe4f commit f37da9c

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

features/plugin.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,27 @@ Feature: Manage WordPress plugins
317317
Automattic
318318
"""
319319

320+
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
321+
And save STDOUT as {LAST_UPDATED}
322+
323+
When I run `wp plugin list --skip-update-check`
324+
Then STDOUT should not be empty
325+
326+
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
327+
Then STDOUT should be:
328+
"""
329+
{LAST_UPDATED}
330+
"""
331+
332+
When I run `wp plugin list`
333+
Then STDOUT should not be empty
334+
335+
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
336+
Then STDOUT should not contain:
337+
"""
338+
{LAST_UPDATED}
339+
"""
340+
320341
Scenario: List plugin by multiple statuses
321342
Given a WP multisite install
322343
And a wp-content/plugins/network-only.php file:

features/theme.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,34 @@ Feature: Manage WordPress themes
233233
| name | status | update |
234234
| astra | inactive | none |
235235

236+
237+
Scenario: Doing wp theme list does a force check by default, deleting any existing transient values
238+
Given a WP install
239+
240+
When I run `wp theme list`
241+
Then STDOUT should not be empty
242+
243+
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
244+
And save STDOUT as {LAST_UPDATED}
245+
246+
When I run `wp theme list --skip-update-check`
247+
Then STDOUT should not be empty
248+
249+
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
250+
Then STDOUT should be:
251+
"""
252+
{LAST_UPDATED}
253+
"""
254+
255+
When I run `wp theme list`
256+
Then STDOUT should not be empty
257+
258+
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
259+
Then STDOUT should not contain:
260+
"""
261+
{LAST_UPDATED}
262+
"""
263+
236264
Scenario: Install a theme when the theme directory doesn't yet exist
237265
Given a WP install
238266
And I run `wp theme delete --all --force`

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ protected function _list( $_, $assoc_args ) {
543543

544544
// Force WordPress to check for updates if `--skip-update-check` is not passed.
545545
if ( false === (bool) Utils\get_flag_value( $assoc_args, 'skip-update-check', false ) ) {
546+
delete_site_transient( $this->upgrade_transient );
546547
call_user_func( $this->upgrade_refresh );
547548
}
548549

0 commit comments

Comments
 (0)