Skip to content

Commit 81bacae

Browse files
committed
[TASK] Avoid caching for fluid string parsing
1 parent a84eee4 commit 81bacae

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7+
*
8+
* For the full copyright and license information, please read the
9+
* LICENSE.txt file that was distributed with this source code.
10+
*/
11+
12+
namespace DERHANSEN\SfEventMgt\Security;
13+
14+
use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface;
15+
use TYPO3Fluid\Fluid\Core\Cache\FluidCacheWarmerInterface;
16+
use TYPO3Fluid\Fluid\Core\Cache\StandardCacheWarmer;
17+
18+
/**
19+
* A no-op Fluid cache implementation that never stores or returns compiled templates.
20+
* Used in parseStringFluid() to ensure templates are always parsed from source,
21+
* so that AllowedViewHelperInvoker is invoked on every render.
22+
*/
23+
class NullFluidCache implements FluidCacheInterface
24+
{
25+
public function get(string $name): mixed
26+
{
27+
return null;
28+
}
29+
30+
public function set(string $name, mixed $value): void {}
31+
32+
public function flush(?string $name = null): void {}
33+
34+
public function getCacheWarmer(): FluidCacheWarmerInterface
35+
{
36+
return new StandardCacheWarmer();
37+
}
38+
}

Classes/Service/FluidRenderingService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace DERHANSEN\SfEventMgt\Service;
1313

1414
use DERHANSEN\SfEventMgt\Security\AllowedViewHelperInvoker;
15+
use DERHANSEN\SfEventMgt\Security\NullFluidCache;
1516
use TYPO3\CMS\Core\Http\ApplicationType;
1617
use TYPO3\CMS\Core\Utility\GeneralUtility;
1718
use TYPO3\CMS\Core\View\ViewFactoryData;
@@ -83,6 +84,7 @@ public function parseString(
8384
1727434457
8485
);
8586
}
87+
$view->getRenderingContext()->setCache(new NullFluidCache());
8688
$view->getRenderingContext()->setViewHelperInvoker(new AllowedViewHelperInvoker());
8789
$view->getRenderingContext()->setTemplateProcessors([
8890
new NamespaceDetectionTemplateProcessor(),

0 commit comments

Comments
 (0)