From 058a267d079a8a8d018c05e1aa03dc784a83bc32 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Thu, 7 Sep 2017 17:59:15 -0700
Subject: [PATCH] When the spawned command fails, return its error rather than
 killing the cron runner

---
 includes/run.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/includes/run.php b/includes/run.php
index 05b8ceb..4377f8d 100644
--- a/includes/run.php
+++ b/includes/run.php
@@ -23,7 +23,9 @@ function run_event( $command ) {
 	$start = microtime( true );
 
 	$output = \WP_CLI::runcommand( $command, array(
-		'return' => 'all',
+		'exit_error' => false, // Don't kill the cron process if the WP-CLI command fails, otherwise we can't capture the error
+		'launch'     => true,  // Don't reuse as we're in cron context
+		'return'     => 'all', // We want STDERR and the exit code, in addition to STDOUT
 	) );
 
 	$end = microtime( true );
-- 
GitLab