From 55215cf4a45c8fdad704f41fe77d11fe7f646924 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Mon, 1 Dec 2025 18:39:44 +0100 Subject: [PATCH] [12.x] Fix cache:clear command exit code on failure The cache:clear command was returning void (exit code 0) even when the cache flush operation failed. This made it impossible for automation tools and CI/CD pipelines to detect cache clear failures. Changes: - Return self::FAILURE when cache flush fails - Return self::SUCCESS on successful cache clear - Update return type from void to int --- src/Illuminate/Cache/Console/ClearCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Cache/Console/ClearCommand.php b/src/Illuminate/Cache/Console/ClearCommand.php index e84cefae8d6c..629587f859e5 100755 --- a/src/Illuminate/Cache/Console/ClearCommand.php +++ b/src/Illuminate/Cache/Console/ClearCommand.php @@ -57,7 +57,7 @@ public function __construct(CacheManager $cache, Filesystem $files) /** * Execute the console command. * - * @return void + * @return int */ public function handle() { @@ -70,7 +70,9 @@ public function handle() $this->flushFacades(); if (! $successful) { - return $this->components->error('Failed to clear cache. Make sure you have the appropriate permissions.'); + $this->components->error('Failed to clear cache. Make sure you have the appropriate permissions.'); + + return self::FAILURE; } $this->laravel['events']->dispatch( @@ -78,6 +80,8 @@ public function handle() ); $this->components->info('Application cache cleared successfully.'); + + return self::SUCCESS; } /**