Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Classes/Middleware/DisableCacheInEditModeMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace TYPO3\CMS\VisualEditor\Middleware;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Frontend\Cache\CacheInstruction;

readonly class DisableCacheInEditModeMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$params = $request->getQueryParams();
if (isset($params['editMode'])) {
$cacheInstruction = $request->getAttribute('frontend.cache.instruction', new CacheInstruction());
$cacheInstruction->disableCache('EXT:visual_editor: The editMode parameter forced the cache to be disabled.');
$request = $request->withAttribute('frontend.cache.instruction', $cacheInstruction);
}

return $handler->handle($request);
}
}
11 changes: 11 additions & 0 deletions Configuration/RequestMiddlewares.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use TYPO3\CMS\VisualEditor\Middleware\DisableCacheInEditModeMiddleware;
use TYPO3\CMS\VisualEditor\Middleware\PersistenceMiddleware;

return [
Expand All @@ -15,5 +16,15 @@
'typo3/cms-adminpanel/sql-logging',
],
],
'typo3/cms-visual-editor/disable-cache-in-edit-mode-middleware' => [
'target' => DisableCacheInEditModeMiddleware::class,
'before' => [
'typo3/cms-frontend/page-argument-validator',
'typo3/cms-frontend/prepare-tsfe-rendering',
'typo3/cms-frontend/tsfe', // TODO typo3/cms-frontend/tsfe can be dropped if TYPO3 14 is lowest supported version
'typo3/cms-frontend/page-resolver',
'typo3/cms-adminpanel/sql-logging',
],
],
],
];
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"pluswerk/grumphp-config": "^10.2.7",
"saschaegerer/phpstan-typo3": "^2.1.1 || ^3.0.1",
"ssch/typo3-rector": "^3.14.1",
"typo3/cms-install": "^13.4.28 || ^14.3.0",
"typo3/cms-workspaces": "^13.4.28 || ^14.3.0",
"typo3/cms-install": "^13.4.28 || ^14.3.2",
"typo3/cms-workspaces": "^13.4.28 || ^14.3.2",
"typo3/testing-framework": "^9.5.0",
"typo3fluid/fluid": "^4.6.1 || ^5.3.1"
},
Expand Down
4 changes: 0 additions & 4 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@
if (!class_exists(ModifyRenderedContentAreaEvent::class)) {
class_alias(V13_RenderContentAreaEvent::class, ModifyRenderedContentAreaEvent::class);
}

// exclude editMode from chash: If the parameter is present, the middleware already stops the normal rendering.
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'] ??= [];
$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'editMode';