From fafe6a2ea42e69bf077ccf1107be62ae99d70eb4 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Sun, 30 Jun 2024 10:38:00 +0100 Subject: [PATCH] a bit more defensiveness about add_retriever_item --- retriever/retriever.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/retriever/retriever.php b/retriever/retriever.php index 639d96c6..c0f6f935 100644 --- a/retriever/retriever.php +++ b/retriever/retriever.php @@ -448,7 +448,9 @@ function retriever_on_item_insert(array $retriever, array &$item) { } $resource = add_retriever_resource($url, $item['uid'], $item['contact-id']); - $retriever_item_id = add_retriever_item($item, $resource); + if (is_array($resource)) { + $retriever_item_id = add_retriever_item($item, $resource); + } } /** @@ -744,12 +746,15 @@ function retrieve_images(array &$item) { } if (strpos($url, (string)(DI::baseUrl())) === FALSE) { $resource = add_retriever_resource($url, $item['uid'], $item['contact-id'], true); + if (!is_array($resource)) { + Logger::error('retrieve_images: could not add resource', ['url' => $url, 'uid' => $item['uid'], 'contact-id' => $item['contact-id']]); + continue; + } if (!$resource['completed']) { add_retriever_item($item, $resource); + continue; } - else { - retriever_transform_images($item, $resource); - } + retriever_transform_images($item, $resource); } } }