From 670c5abaaea3c32c6ae17f62155445462f3be7e9 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Mon, 24 Jan 2022 17:36:12 +0100 Subject: [PATCH] chg: [outboxProcessors:brood] Gracefully catch server errors on remote broods --- .../default/OutboxProcessors/BroodsOutboxProcessor.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/default/OutboxProcessors/BroodsOutboxProcessor.php b/libraries/default/OutboxProcessors/BroodsOutboxProcessor.php index 9019857..9bf79ae 100644 --- a/libraries/default/OutboxProcessors/BroodsOutboxProcessor.php +++ b/libraries/default/OutboxProcessors/BroodsOutboxProcessor.php @@ -110,6 +110,14 @@ class ResendFailedMessageProcessor extends BroodsOutboxProcessor implements Gene $dataSent = $outboxRequest->data['sent']; $response = $this->Broods->sendRequest($brood, $url, true, $dataSent); $jsonReply = $response->getJson(); + if (is_null($jsonReply)) { + $jsonReply = [ + 'success' => false, + 'errors' => [ + __('Brood returned an invalid JSON.') + ] + ]; + } $success = !empty($jsonReply['success']); $messageSuccess = __('Message successfully sent to `{0}`', $brood->name); $messageFail = __('Could not send message to `{0}`.', $brood->name);