Skip to content
Snippets Groups Projects
Commit c82de6d0 authored by Jonas Schwabe's avatar Jonas Schwabe Committed by Daniel Goerz
Browse files

[BUGFIX] ImmediateResponseException needs to be relayed

ImmediateResponseException were not handled correctly during content
object rendering when running in a production environment.
This patch makes sure that ImmediateResponses are handled as such instead
of just printing them during template rendering.

Resolves: #88080
Releases: master, 9.5
Change-Id: Id211b4064b438b3df0744c7a0de90b642ed872de
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60370


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarJonas Schwabe <jonas.schwabe@eyeworkers.de>
Tested-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarJonas Schwabe <jonas.schwabe@eyeworkers.de>
Reviewed-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 78893b32
Branches
Tags
No related merge requests found
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Exception;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Http\ImmediateResponseException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;
......@@ -54,6 +55,11 @@ class ProductionExceptionHandler implements ExceptionHandlerInterface, LoggerAwa
*/
public function handle(\Exception $exception, AbstractContentObject $contentObject = null, $contentObjectConfiguration = [])
{
// ImmediateResponseException should work similar to exit / die and must therefore not be handled by this ExceptionHandler.
if ($exception instanceof ImmediateResponseException) {
throw $exception;
}
if (!empty($this->configuration['ignoreCodes.'])) {
if (in_array($exception->getCode(), array_map('intval', $this->configuration['ignoreCodes.']), true)) {
throw $exception;
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Exception;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\NullLogger;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\ImmediateResponseException;
use TYPO3\CMS\Frontend\ContentObject\Exception\ProductionExceptionHandler;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* Test case
*/
class ProductionExceptionHandlerTest extends UnitTestCase
{
/**
* @var ProductionExceptionHandler
*/
protected $subject;
/**
* Sets up this test case.
*/
protected function setUp(): void
{
$this->subject = new ProductionExceptionHandler();
$this->subject->setLogger(new NullLogger());
}
/**
* @test
*/
public function relayImmediateResponseException()
{
$response = $this->getMockBuilder(HtmlResponse::class)
->disableOriginalConstructor()
->getMock();
$exception = new ImmediateResponseException($response, 1533939251);
$this->expectException(ImmediateResponseException::class);
$this->subject->handle($exception);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment