From ee3fffc55eb6ebb1bed4dbc8e296f0575814d68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wolda=C5=84ski?= Date: Fri, 2 Feb 2024 16:09:05 +0100 Subject: [PATCH] [BUGFIX] Fix warning & mixed-mode handling - additional code cleanup --- Classes/XClass/ResourceLocalDriver.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Classes/XClass/ResourceLocalDriver.php b/Classes/XClass/ResourceLocalDriver.php index 4fc5f8ab..404722c2 100644 --- a/Classes/XClass/ResourceLocalDriver.php +++ b/Classes/XClass/ResourceLocalDriver.php @@ -26,19 +26,22 @@ class ResourceLocalDriver extends LocalDriver { protected function determineBaseUrl(): void { - $headlessMode = GeneralUtility::makeInstance(HeadlessMode::class)->withRequest($GLOBALS['TYPO3_REQUEST']); + $request = $GLOBALS['TYPO3_REQUEST'] ?? null; - if ((($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface - && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) || - !$headlessMode->isEnabled()) { + if (!$request instanceof ServerRequestInterface) { + return; + } + + $headlessMode = GeneralUtility::makeInstance(HeadlessMode::class)->withRequest($request); + + if (!$headlessMode->isEnabled() || ApplicationType::fromRequest($request)->isBackend()) { parent::determineBaseUrl(); return; } - if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface && - $this->hasCapability(ResourceStorage::CAPABILITY_PUBLIC)) { - $urlUtility = GeneralUtility::makeInstance(UrlUtility::class); + if ($this->hasCapability(ResourceStorage::CAPABILITY_PUBLIC)) { + $urlUtility = GeneralUtility::makeInstance(UrlUtility::class)->withRequest($request); $this->configuration['baseUri'] = $urlUtility->getStorageProxyUrl(); }