From 4807590b1381248c0be60e2a1d536c48e7973e95 Mon Sep 17 00:00:00 2001 From: MGatner Date: Tue, 27 Aug 2019 14:17:00 -0400 Subject: [PATCH 1/3] Spark exit for error codes --- spark | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spark b/spark index 10079e4ebc15..396ad59c4803 100755 --- a/spark +++ b/spark @@ -53,5 +53,9 @@ ini_set('display_errors', 1); // Show basic information before we do anything else. $console->showHeader(); -// fire off the command the main framework. -$console->run(); +// fire off the command in the main framework. +$response = $console->run(); +if ($response->getStatusCode() >= 300) +{ + exit($response->getStatusCode()); +} From e91d0e719d2a4201b6e68295c4952229ad6d4942 Mon Sep 17 00:00:00 2001 From: MGatner Date: Tue, 27 Aug 2019 14:17:56 -0400 Subject: [PATCH 2/3] Set error code for Command failures --- system/CodeIgniter.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 4222c336b300..8d332dcd126b 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -355,6 +355,12 @@ protected function handleRequest(RouteCollectionInterface $routes = null, $cache else { $response = $this->response; + + // Set response code for CLI command failures + if (is_numeric($returned) || $returned === false) + { + $response->setStatusCode(400); + } } if ($response instanceof Response) From 279e71e59ca3a374c109d04b1597bc4af0b16407 Mon Sep 17 00:00:00 2001 From: MGatner Date: Tue, 27 Aug 2019 14:18:43 -0400 Subject: [PATCH 3/3] CommandRunner _remap returns index() value --- system/CLI/CommandRunner.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php index 00c78747e489..2d811249cd09 100644 --- a/system/CLI/CommandRunner.php +++ b/system/CLI/CommandRunner.php @@ -71,6 +71,7 @@ class CommandRunner extends Controller * @param string $method * @param array ...$params * + * @return mixed * @throws \ReflectionException */ public function _remap($method, ...$params) @@ -81,7 +82,7 @@ public function _remap($method, ...$params) array_shift($params); } - $this->index($params); + return $this->index($params); } //--------------------------------------------------------------------