From e596bcd5984ed258e23211225f072ecf1aff4486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remo=20H=C3=A4usler?= Date: Wed, 24 Jul 2024 17:15:29 +0200 Subject: [PATCH] Fix exception for NullSite in backend context --- Classes/Middleware/Oauth2Configuration.php | 7 ++++++- composer.json | 2 +- ext_emconf.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Classes/Middleware/Oauth2Configuration.php b/Classes/Middleware/Oauth2Configuration.php index 4817ccf..cd89988 100644 --- a/Classes/Middleware/Oauth2Configuration.php +++ b/Classes/Middleware/Oauth2Configuration.php @@ -11,6 +11,7 @@ use R3H6\Oauth2Server\ExceptionHandlingTrait; use R3H6\Oauth2Server\Http\RequestAttribute; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Utility\GeneralUtility; /*** @@ -33,7 +34,11 @@ class Oauth2Configuration implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - $siteConfiguration = $request->getAttribute('site')->getConfiguration()['oauth2'] ?? false; + $site = $request->getAttribute('site'); + if (!$site instanceof Site) { + return $handler->handle($request); + } + $siteConfiguration = $site->getConfiguration()['oauth2'] ?? false; if ($siteConfiguration === false || !($siteConfiguration['enabled'] ?? true)) { return $handler->handle($request); } diff --git a/composer.json b/composer.json index c6f3ba5..c64fc1d 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "ci:php:stan": "phpstan --no-progress", "ci:test:unit": "phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/", "ci:libs:pack": "phar-composer build softcreatr/jsonpath Resources/Private/Php/jsonpath.phar", - "fix:php:cs": "php-cs-fixer fix --config .php-cs-fixer.php" + "fix:php:cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config .php-cs-fixer.php" }, "extra": { "typo3/cms": { diff --git a/ext_emconf.php b/ext_emconf.php index 0e99892..158b26b 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -19,7 +19,7 @@ 'state' => 'beta', 'createDirs' => '', 'clearCacheOnLoad' => 0, - 'version' => '1.5.3', + 'version' => '1.5.4', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.0-11.5.99',