Skip to content

Commit

Permalink
[BUGFIX] Prevent application type exception in ViewHelper
Browse files Browse the repository at this point in the history
In case the "f:format.html" ViewHelper is called
in the install tool or via CLI, there might be either
no request object or one without an application
type. This led to an exception on checking the
application type.

This is now fixed by checking the request before
calling the static ApplicationType check.

Resolves: #96788
Releases: main, 11.5
Change-Id: I1e48a3556d510d2af82d4f95828d44c182db0663
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73422
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Feb 11, 2022
1 parent ab6a457 commit 9e0e316
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@

namespace TYPO3\CMS\Fluid\ViewHelpers\Format;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand Down Expand Up @@ -146,8 +147,11 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$current = $arguments['current'];
$currentValueKey = $arguments['currentValueKey'];
$table = $arguments['table'];
$isBackendRequest = ApplicationType::fromRequest($renderingContext->getRequest())->isBackend();

$request = $renderingContext->getRequest();
$isBackendRequest = $request instanceof ServerRequestInterface
&& $request->getAttribute('applicationType')
&& ApplicationType::fromRequest($request)->isBackend();
if ($isBackendRequest) {
$tsfeBackup = self::simulateFrontendEnvironment();
}
Expand Down

0 comments on commit 9e0e316

Please sign in to comment.