From 2021c3dd9b2c5515dce245c0fd878d31ecdd82e3 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 15 May 2022 23:02:57 -0700 Subject: [PATCH] CRM_Utils_Check - Catch Guzzle exception, same as core exception Overview -------- `checkExtensions()` is supposed to show status-messages which report on any out-of-date extensions. This requires a list of available updates. Alas, the Internet is a big and scary place, and sometimes the list is unavailable. DNS servers, HTTP servers, timeouts, yadda yadda. If it can't get the list of extensions, it should show a status-message about this problem. Before ------ Throws an exception, causing a full failure in the page-view that does the status-check. After ----- Catches the exception. Reports a status-message about the failure. Comments -------- It appears that this was probably the behavior before (ie `checkExtension()` already has a try/catch for this kind of problem). However, the underlying HTTP request was changed a versions back (ie from `HttpClient` to `Guzzle`) which means that errors can get reported in other ways. To simulate errors, I did this: 1. Run buggy/placeholder TCP service (`nc -l 8199`) 2. Hack `CRM_Extension_Browser::__construct()` to set `$this->repoUrl` to `http://localhost:8199` 3. Run `cv api System.check` --- CRM/Utils/Check/Component/Env.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 39e1e3dde9..3476dba691 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -587,7 +587,7 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component { try { $remotes = $extensionSystem->getBrowser()->getExtensions(); } - catch (CRM_Extension_Exception $e) { + catch (CRM_Extension_Exception | \GuzzleHttp\Exception\GuzzleException $e) { $messages[] = new CRM_Utils_Check_Message( __FUNCTION__, $e->getMessage(), -- 2.25.1