From 85176ea5c21f429576abbeded80a5f8667340842 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 11 Feb 2021 12:46:54 +0100 Subject: [PATCH] Replace GuzzleException by ClientExceptionInterface ClientExceptionInterface is the standardized Exception and thus preferable. GuzzleException extends that interface. --- .../install/files/lib/action/AbstractOauth2Action.class.php | 6 +++--- .../install/files/lib/action/GithubAuthAction.class.php | 4 ++-- .../install/files/lib/data/user/avatar/Gravatar.class.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php b/wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php index c9569871d4..19764d66c9 100644 --- a/wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php +++ b/wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php @@ -3,9 +3,9 @@ namespace wcf\action; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Psr7\Request; use ParagonIE\ConstantTime\Hex; +use Psr\Http\Client\ClientExceptionInterface; use wcf\system\exception\NamedUserException; use wcf\system\exception\PermissionDeniedException; use wcf\system\io\HttpFactory; @@ -148,7 +148,7 @@ abstract class AbstractOauth2Action extends AbstractAction // access_token to invalidate 'code'. // // Validation is happening within the `finally` so that the StateValidationException - // overwrites any GuzzleException (improving the error message). + // overwrites any HTTP exception (improving the error message). if ($this->supportsState()) { $this->validateState(); } @@ -229,7 +229,7 @@ abstract class AbstractOauth2Action extends AbstractAction $exceptionID = \wcf\functions\exception\logThrowable($e); $type = 'genericException'; - if ($e instanceof GuzzleException) { + if ($e instanceof ClientExceptionInterface) { $type = 'httpError'; } diff --git a/wcfsetup/install/files/lib/action/GithubAuthAction.class.php b/wcfsetup/install/files/lib/action/GithubAuthAction.class.php index 54268b846c..a8a034e3b1 100644 --- a/wcfsetup/install/files/lib/action/GithubAuthAction.class.php +++ b/wcfsetup/install/files/lib/action/GithubAuthAction.class.php @@ -2,8 +2,8 @@ namespace wcf\action; -use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Psr7\Request; +use Psr\Http\Client\ClientExceptionInterface; use wcf\data\user\User; use wcf\form\RegisterForm; use wcf\system\exception\NamedUserException; @@ -162,7 +162,7 @@ final class GithubAuthAction extends AbstractOauth2Action } } $oauthUser["__email"] = $email; - } catch (GuzzleException $e) { + } catch (ClientExceptionInterface $e) { } WCF::getSession()->register('__oauthUser', $oauthUser); diff --git a/wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php b/wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php index ae4c92fbc2..16f1f8da30 100644 --- a/wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php +++ b/wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php @@ -2,8 +2,8 @@ namespace wcf\data\user\avatar; -use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Psr7\Request; +use Psr\Http\Client\ClientExceptionInterface; use wcf\system\io\HttpFactory; use wcf\system\request\LinkHandler; use wcf\system\WCF; @@ -119,7 +119,7 @@ class Gravatar extends DefaultAvatar if ($response->getStatusCode() === 200) { return true; } - } catch (GuzzleException $e) { + } catch (ClientExceptionInterface $e) { // Ignore exception, because we return false anyways. } -- 2.20.1