85224[BUGFIX] Use new container instance for sub request in PageContentErrorHandler
Commit message
Review
-
Code review CR 0
-
Verified V -1
- Christian Weiske -1
- core-ci -1 CI
Issues 2
Files 1
Review log 2023
-
Torben Hansen uploaded patch set 1 07/11/24, 12:11
-
core-ci voted on patch set 1 V +1 07/11/24, 12:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61382
-
Christian Kuhn commented on patch set 1 CR -1 07/11/24, 18:09
-
Torben Hansen commented on patch set 1 07/12/24, 08:22
PageContentErrorHandler.php:144ReplyI tried, but with no success. The `PageRenderer` is not available in `GeneralUtility::getSingletonInstances()`, but is injected using DI as far as I can see. So the `PageRenderer` instance should be removed from DI somehow, but I have no idea how to archive this. -
Torben Hansen uploaded patch set 2
CR -1V +107/13/24, 15:23 -
Torben Hansen commented on patch set 2 07/13/24, 15:27
PageContentErrorHandler.php:144ReplyUsed a different approach now and we park the existing container, perform the sub request with a fresh instance of container from `BootService` and finally set the parked container back. -
core-ci voted on patch set 2 V +1 07/13/24, 15:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61542
-
Markus Klein commented on patch set 2 CR +1 07/18/24, 06:23
Makes sense to me, but reveals yet again, that we are far away from encapsulated (sub) request-handling. -
Simon Schaufelberger voted on patch set 2 CR +1 V +1 07/18/24, 07:03
-
Georg Ringer voted on patch set 2 CR +1 V +1 07/19/24, 06:33
-
Markus Klein voted on patch set 2 V +1 07/26/24, 07:14
-
Timo Webler commented on patch set 2 08/14/24, 10:07
PageContentErrorHandler.php:121UnresolvedThis does not reset the current container. The bootstrap service generate no new container if already one is available. I implement an nasty workaround for it. I hope the core developers will find an better solution for that. ``` /** * Reset content within page renderer for sub request. * * @see https://forge.typo3.org/issues/103215 */ protected function stashEnvironment(callable $fetcher): ResponseInterface { $parkedTsfe = $GLOBALS['TSFE'] ?? null; $GLOBALS['TSFE'] = null; /** @var BootService $bootService */ $bootService = GeneralUtility::makeInstance(BootService::class); $backup = $bootService->makeCurrent($this->getNewContainer($bootService)); $result = $fetcher(); $GLOBALS['TSFE'] = $parkedTsfe; $bootService->makeCurrent(null, $backup); return $result; } protected function getNewContainer(BootService $bootService): ContainerInterface { $callPrivateMethod = function ($object, $method, ...$args) { $call = function ($method, ...$args) { return $this->$method(...$args); }; $newCall = $call->bindTo($object, get_class($object)); return $newCall($method, ...$args); }; return $callPrivateMethod($bootService, 'prepareContainer'); } ``` -
Guido Schmechel commented on patch set 2 V +1 09/28/24, 15:31
I can confirm that this has solved the problem for me. I cannot judge whether the code is good enough in this case. -
Benjamin Franzke commented on patch set 2 CR -1 10/01/24, 11:30
Sorry, but we don't want multiple containers, as we want our services to become stateless. I'm aware that is was too early to use sub-requests for 404, but we should rather fix the page renderer state (intermediate fix would be to use the existing update/set state methods), rather then parking the entire container. -1 for now… -
Oliver Hader updated the commit message in patch set 3
CR +1V +110/18/24, 14:02 -
Christian Weiske commented on patch set 3 09/19/25, 10:44
So instead of fixing this bug that exists *now*, we'll wait until the holy land is reached some time in the future? -
Christian Weiske commented on patch set 3 09/22/25, 09:38
There is a regression with that patch: https://forge.typo3.org/issues/107515 The list of storages gets reset, and loading a image file from a non-local storage on the error page leads to an exception: > Desired storage "AusDriverAmazonS3" is not in the list of available storages. -
Christian Weiske commented on patch set 3 09/22/25, 10:05
Reply Unresolved
There is currently no way to reset the page renderer to a clean state from outside. reset() does not reset everything and is protected. Replacing the renderer in the container does not work either: "The "TYPO3\CMS\Core\Page\PageRenderer" service is already initialized, you cannot replace it." -
Oliver Klee updated the commit message in patch set 4 09/22/25, 10:25
-
core-ci voted on patch set 4 V -1 09/22/25, 10:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85284
-
Christian Weiske commented on patch set 4 V -1 10/08/25, 16:01
There is another regression with that patch: When a content element on the 404 page tries to check if the preview context is set, a new exception occurs: ``` TYPO3\CMS\Core\Context\Exception\AspectNotFoundException No aspect named "frontend.preview" found. #0 /vendor/typo3/cms-core/Classes/Context/Context.php(152): TYPO3\CMS\Core\Context\Context::getPropertyFromAspect #1 /vendor/fluidtypo3/flux/Classes/Service/RecordService.php(163): FluidTYPO3\Flux\Service\RecordService::isPreviewContext #2 /vendor/fluidtypo3/flux/Classes/Service/RecordService.php(150): FluidTYPO3\Flux\Service\RecordService::isBackendOrPreviewContext #3 /vendor/fluidtypo3/flux/Classes/Service/RecordService.php(63): FluidTYPO3\Flux\Service\RecordService::getSingle #4 /vendor/fluidtypo3/flux/Classes/Service/WorkspacesAwareRecordService.php(37): FluidTYPO3\Flux\Service\WorkspacesAwareRecordService::getSingle #5 /vendor/fluidtypo3/flux/Classes/ViewHelpers/Form/DataViewHelper.php(98): FluidTYPO3\Flux\ViewHelpers\Form\DataViewHelper::renderStatic ``` -
Torben Hansen abandoned the change 10/17/25, 13:36
Container parking is no real solution for this. I'll try to provide an alternative intermediate patch to resolve the problem. -
Christian Weiske commented on patch set 4 01/12/26, 09:01
Alternative Patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/91127
PageContentErrorHandler.php:144