Skip to content

Commit

Permalink
CRM_Utils_Check - Catch Guzzle exception, same as core exception
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
totten committed May 16, 2022
1 parent 935d142 commit 2021c3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CRM/Utils/Check/Component/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public function checkExtensions() {
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(),
Expand Down

0 comments on commit 2021c3d

Please sign in to comment.