From d8ef33a081250b956c83885258a1bd0045f91398 Mon Sep 17 00:00:00 2001 From: Clement Boirie Date: Tue, 12 Dec 2023 09:21:44 +0100 Subject: [PATCH] new feature test for calling cache pluck command with invalid key --- features/cache-pluck.feature | 7 +++++++ src/Cache_Command.php | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/features/cache-pluck.feature b/features/cache-pluck.feature index 82583ee5..c5d08288 100644 --- a/features/cache-pluck.feature +++ b/features/cache-pluck.feature @@ -31,3 +31,10 @@ Feature: Pluck command available for the object cache """ bar_custom """ + + When I try `wp cache pluck unknown_key test` + Then STDERR should be: + """ + Warning: No object found for the key "unknown_key" in group "default" + """ + diff --git a/src/Cache_Command.php b/src/Cache_Command.php index 751258bb..6205959b 100644 --- a/src/Cache_Command.php +++ b/src/Cache_Command.php @@ -444,7 +444,8 @@ public function pluck( $args, $assoc_args ) { $value = wp_cache_get( $key, $group ); if ( false === $value ) { - WP_CLI::halt( 1 ); + WP_CLI::warning( 'No object found for the key "' . $key . '" in group "' . $group . '"' ); + exit; } $key_path = array_map(