#103215PageContentErrorHandler attaches error output to current response's output instead of replacing it.
Description
When a non-cacheable plugin throws a PropagateResponseException with the response of TYPO3\CMS\Frontend\Controller\ErrorController->pageNotFoundAction(), this response gets attached to the output of the originally requested page.
Background:
Since TYPO3 v12 TYPO3\CMS\Core\Error\PageErrorHandler\PageContentErrorHandler uses a sub-request to render and fetch the content of the configured 404 page. In earlier versions of TYPO3 this was done with a curl request. TYPO3 v11 introduced an experimental and optional feature to use a sub-request (feature: #94402), which was set as standard behaviour within TYPO3 v12 (https://forge.typo3.org/issues/98396).
Problem:
Though the sub-request to fetch the 404 content is done as a new request, the underlying TYPO3\CMS\Core\Page\PageRenderer is a singleton. So, it still holds the already rendered (HTML) output of the original request in its property $bodyContent. During the process of rendering the sub-request, the content of the 404 page is then only added to this content. What is even more annoying: This faulty 404 content will be cached and then delivered whenever a 404 error occurs.
Proposed solution:
Before sending the sub-request, PageContentErrorHandler should clear PageRenderer->bodyContent to make sure only the output of the 404 page is rendered. Perhaps like so:
protected function sendSubRequest(ServerRequestInterface $request, int $pageId, ServerRequestInterface $originalRequest): ResponseInterface
{
$site = $request->getAttribute('site');
if (!$site instanceof Site) {
$site = $this->siteFinder->getSiteByPageId($pageId);
$request = $request->withAttribute('site', $site);
}
$request = $request->withAttribute('originalRequest', $originalRequest);
// Reset already rendered content of the original request/response
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->setBodyContent('');
return $this->application->handle($request);
}
Another possible solution would be to reset the entire singleton instance of PageRenderer via GeneralUtility::removeSingletonInstance().
To reproduce this problem:
1. Have a non-cacheable (!) Extbase plugin that throws an Exception like this (FQDN only for not being ambiguous):
public function pageNotFoundAction(): ResponseInterface
{
$errorController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Controller\ErrorController\ErrorController::class);
$response = $errorController->pageNotFoundAction(
$GLOBALS['TYPO3_REQUEST'],
'Content unavailable',
[
'code' => \TYPO3\CMS\Frontend\Page\PageAccessFailureReasons\PageAccessFailureReasons::PAGE_NOT_FOUND,
]
);
throw new \TYPO3\CMS\Core\Http\PropagateResponseException\PropagateResponseException($response);
return $this->htmlResponse();
}
2. Place that plugin on a page
3. Inside your site config have a page based error handling for 404 errors like so
errorHandling:
-
errorCode: 404
errorHandler: Page
errorContentSource: 't3://page?uid=xxxx'
3. Make sure the entire TYPO3 cache has been cleared
4. Request the page containing the plugin with a client
Reviews 3
Related issues 2
History 521
-
Christian Weiske commented <span data-processor="relativetime" data-value="2024-04-08T10:43:28+00:00" > 04/08/24, 10:43 </span>
-
Christian Weiske changed Related to #98396 <span data-processor="relativetime" data-value="2024-04-08T10:44:04+00:00" > 04/08/24, 10:44 </span>
-
Georg Ringer changed Duplicated by #104320 <span data-processor="relativetime" data-value="2024-07-07T08:17:56+00:00" > 07/07/24, 08:17 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 85224 status
NewUnder Review <span data-processor="relativetime" data-value="2024-07-11T12:11:36+00:00" > 07/11/24, 12:11 </span> -
Gerrit Code Review pushed patch set 2 for main to change 85224 <span data-processor="relativetime" data-value="2024-07-13T15:23:33+00:00" > 07/13/24, 15:23 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 85224 <span data-processor="relativetime" data-value="2024-10-18T14:02:10+00:00" > 10/18/24, 14:02 </span>
-
Christian Weiske changed Related to #107515 <span data-processor="relativetime" data-value="2025-09-22T09:39:02+00:00" > 09/22/25, 09:39 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 85224 <span data-processor="relativetime" data-value="2025-09-22T10:25:14+00:00" > 09/22/25, 10:25 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 91127 <span data-processor="relativetime" data-value="2025-10-17T13:40:00+00:00" > 10/17/25, 13:40 </span>
-
Gerrit Code Review pushed patch set 2 for main to change 91127 <span data-processor="relativetime" data-value="2025-10-17T13:51:36+00:00" > 10/17/25, 13:51 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 91127 <span data-processor="relativetime" data-value="2025-12-09T06:38:33+00:00" > 12/09/25, 06:38 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 91127 <span data-processor="relativetime" data-value="2025-12-09T08:00:02+00:00" > 12/09/25, 08:00 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 91127 <span data-processor="relativetime" data-value="2026-03-30T20:06:45+00:00" > 03/30/26, 20:06 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 91127 <span data-processor="relativetime" data-value="2026-04-22T06:44:48+00:00" > 04/22/26, 06:44 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 91127 <span data-processor="relativetime" data-value="2026-05-09T18:20:28+00:00" > 05/09/26, 18:20 </span>
-
Gerrit Code Review pushed patch set 8 for main to change 91127 <span data-processor="relativetime" data-value="2026-06-21T11:45:08+00:00" > 06/21/26, 11:45 </span>
-
Gerrit Code Review pushed patch set 9 for main to change 91127 <span data-processor="relativetime" data-value="2026-08-24T18:20:07+00:00" > 08/24/26, 18:20 </span>
-
Gerrit Code Review pushed patch set 10 for main to change 91127 <span data-processor="relativetime" data-value="2026-08-25T07:13:30+00:00" > 08/25/26, 07:13 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 95409 <span data-processor="relativetime" data-value="2026-08-25T07:33:30+00:00" > 08/25/26, 07:33 </span>
-
Gerrit Code Review pushed patch set 2 for 14.3 to change 95409 <span data-processor="relativetime" data-value="2026-08-25T08:04:37+00:00" > 08/25/26, 08:04 </span>
-
Torben Hansen commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-08-25T08:35:52+00:00" > 08/25/26, 08:35 </span>Applied in changeset commit:119866d287afb6a06134d0fbe181762e78192fc3.
I see this in TYPO3 12.4.13 with PHP 8.2.
I can confirm that the proposed solution (“Reset already rendered content of the original request/response”) works.