From e24842bf4cf15b921a52d9e6422d5ad99bb2175e Mon Sep 17 00:00:00 2001 From: Stefan Korn Date: Mon, 4 Dec 2023 17:17:47 +0100 Subject: [PATCH] #4075: Catch Guzzle Exception to avoid breaking harvest --- modules/metastore/src/Reference/Referencer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/metastore/src/Reference/Referencer.php b/modules/metastore/src/Reference/Referencer.php index 50eaf23517..a9c596681d 100644 --- a/modules/metastore/src/Reference/Referencer.php +++ b/modules/metastore/src/Reference/Referencer.php @@ -13,6 +13,7 @@ use Drupal\metastore\ResourceMapper; use GuzzleHttp\Client as GuzzleClient; +use GuzzleHttp\Exception\GuzzleException; /** * Metastore referencer service. @@ -342,7 +343,12 @@ private function getRemoteMimeType(string $downloadUrl): ?string { // Perform HTTP Head request against the supplied URL in order to determine // the content type of the remote resource. $client = new GuzzleClient(); - $response = $client->head($downloadUrl); + try { + $response = $client->head($downloadUrl); + } + catch (GuzzleException $exception) { + return $mime_type; + } // Extract the full value of the content type header. $content_type = $response->getHeader('Content-Type'); // Attempt to extract the mime type from the content type header.