Skip to content

Commit b9d6f5e

Browse files
committed
new feature test for calling cache pluck command with invalid key
1 parent 9c1e629 commit b9d6f5e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

features/cache-pluck.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ Feature: Pluck command available for the object cache
3131
"""
3232
bar_custom
3333
"""
34+
35+
When I try `wp cache pluck unknown_key test`
36+
Then STDERR should be:
37+
"""
38+
Warning: No object found for the key "unknown_key" in group "default"
39+
"""
40+

src/Cache_Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ public function pluck( $args, $assoc_args ) {
444444
$value = wp_cache_get( $key, $group );
445445

446446
if ( false === $value ) {
447-
WP_CLI::halt( 1 );
447+
WP_CLI::warning( 'No object found for the key "' . $key . '" in group "' . $group . '"' );
448+
exit;
448449
}
449450

450451
$key_path = array_map(

0 commit comments

Comments
 (0)