Skip to content

Commit 927dd89

Browse files
authored
Merge pull request #122 from wp-cli/chore/bump
2 parents 4e3584e + 6776a13 commit 927dd89

5 files changed

Lines changed: 59 additions & 4 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2.12"
15+
"wp-cli/wp-cli": "^2.13"
1616
},
1717
"require-dev": {
1818
"wp-cli/entity-command": "^1.3 || ^2",

features/cache.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Feature: Managed the WordPress object cache
22

3+
@skip-object-cache
34
Scenario: Default group is 'default'
45
Given a WP install
56
And a wp-content/mu-plugins/test-harness.php file:
@@ -210,3 +211,14 @@ Feature: Managed the WordPress object cache
210211

211212
When I run `wp cache supports set_multiple`
212213
Then the return code should be 0
214+
215+
@require-object-cache
216+
Scenario: Object caches may return success when deleting non-existent objects
217+
Given a WP install
218+
219+
When I run `wp cache delete nonexistentkey`
220+
Then STDOUT should be:
221+
"""
222+
Success: Object deleted.
223+
"""
224+
And the return code should be 0

features/transient.feature

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Feature: Manage WordPress transient cache
5555
Success: Transient deleted.
5656
"""
5757

58+
@skip-object-cache
5859
Scenario: Deleting all transients on single site
5960
Given a WP install
6061
# We set `WP_DEVELOPMENT_MODE` to stop WordPress from automatically creating
@@ -125,6 +126,7 @@ Feature: Manage WordPress transient cache
125126
Warning: Transient with key "foo4" is not set.
126127
"""
127128

129+
@skip-object-cache
128130
Scenario: Deleting expired transients on single site
129131
Given a WP install
130132
And I run `wp transient set foo bar 600`
@@ -196,6 +198,7 @@ Feature: Manage WordPress transient cache
196198
bar4
197199
"""
198200

201+
@skip-object-cache
199202
Scenario: Deleting all transients on multisite
200203
Given a WP multisite install
201204
# We set `WP_DEVELOPMENT_MODE` to stop WordPress from automatically creating
@@ -291,6 +294,7 @@ Feature: Manage WordPress transient cache
291294
Warning: Transient with key "foo6" is not set.
292295
"""
293296

297+
@skip-object-cache
294298
Scenario: Deleting expired transients on multisite
295299
Given a WP multisite install
296300
And I run `wp site create --slug=foo`
@@ -391,6 +395,7 @@ Feature: Manage WordPress transient cache
391395
bar6
392396
"""
393397

398+
@skip-object-cache
394399
Scenario: List transients on single site
395400
Given a WP install
396401
And I run `wp transient set foo bar`
@@ -446,6 +451,7 @@ Feature: Manage WordPress transient cache
446451
foo6,bar6,1321009871
447452
"""
448453

454+
@skip-object-cache
449455
Scenario: List transients on multisite
450456
Given a WP multisite install
451457
# We set `WP_DEVELOPMENT_MODE` to stop WordPress from automatically creating
@@ -504,6 +510,7 @@ Feature: Manage WordPress transient cache
504510
foo6,bar6,1321009871
505511
"""
506512

513+
@skip-object-cache
507514
Scenario: List transients with search and exclude pattern
508515
Given a WP install
509516
And I run `wp transient set foo bar`
@@ -603,3 +610,40 @@ Feature: Manage WordPress transient cache
603610
name
604611
foo4
605612
"""
613+
614+
@require-object-cache
615+
Scenario: Transient database operations warn when external object cache is active
616+
Given a WP install
617+
618+
When I try `wp transient list --format=count`
619+
Then STDERR should be:
620+
"""
621+
Warning: Transients are stored in an external object cache, and this command only shows those stored in the database.
622+
"""
623+
And STDOUT should be:
624+
"""
625+
0
626+
"""
627+
And the return code should be 0
628+
629+
When I try `wp transient delete --all`
630+
Then STDERR should be:
631+
"""
632+
Warning: Transients are stored in an external object cache, and this command only deletes those stored in the database. You must flush the cache to delete all transients.
633+
"""
634+
And STDOUT should be:
635+
"""
636+
Success: No transients found.
637+
"""
638+
And the return code should be 0
639+
640+
When I try `wp transient delete --expired`
641+
Then STDERR should be:
642+
"""
643+
Warning: Transients are stored in an external object cache, and this command only deletes those stored in the database. You must flush the cache to delete all transients.
644+
"""
645+
And STDOUT should be:
646+
"""
647+
Success: No expired transients found.
648+
"""
649+
And the return code should be 0

src/Cache_Command.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ public function delete( $args, $assoc_args ) {
168168
*/
169169
public function flush() {
170170
// TODO: Needs fixing in wp-cli/wp-cli
171-
// @phpstan-ignore offsetAccess.nonOffsetAccessible
172171
if ( WP_CLI::has_config( 'url' ) && ! empty( WP_CLI::get_config()['url'] ) && is_multisite() ) {
173172
WP_CLI::warning( 'Flushing the cache may affect all sites in a multisite installation, depending on the implementation of the object cache.' );
174173
}
@@ -574,7 +573,7 @@ function ( $key ) {
574573
if ( ! empty( $stdin_value ) ) {
575574
$patch_value = WP_CLI::read_value( $stdin_value, $assoc_args );
576575
} elseif ( count( $key_path ) > 1 ) {
577-
$patch_value = WP_CLI::read_value( array_pop( $key_path ), $assoc_args );
576+
$patch_value = WP_CLI::read_value( (string) array_pop( $key_path ), $assoc_args );
578577
} else {
579578
$patch_value = null;
580579
}

src/Transient_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ function ( $key ) {
557557
if ( ! empty( $stdin_value ) ) {
558558
$patch_value = WP_CLI::read_value( $stdin_value, $assoc_args );
559559
} elseif ( count( $key_path ) > 1 ) {
560-
$patch_value = WP_CLI::read_value( array_pop( $key_path ), $assoc_args );
560+
$patch_value = WP_CLI::read_value( (string) array_pop( $key_path ), $assoc_args );
561561
} else {
562562
$patch_value = null;
563563
}

0 commit comments

Comments
 (0)