Commit 45cb70b8 authored by Benni Mack's avatar Benni Mack
Browse files

[!!!][TASK] Remove legacy "pageNotFound_handling" options

With the introduction of site handling, the old "pageNotFound_handling"
mechanisms can be removed. If a site configuration hasn't configured
a error handler, a 404/403/500 response with the default error
renderer is now returned. Making PageNotFoundExceptions rendering
the frontend very seldom.

The following options are removed:
- $TYPO3_CONF_VARS[FE][pageNotFound_handling]
- $TYPO3_CONF_VARS[FE][pageNotFound_handling_statheader]
- $TYPO3_CONF_VARS[FE][pageNotFound_handling_accessdeniedheader]
- $TYPO3_CONF_VARS[FE][pageUnavailable_handling]
- $TYPO3_CONF_VARS[FE][pageUnavailable_handling_statheader]

Tests have been adopted to check against status code / message
rather than on the exceptions (not) thrown (anymore).

In addition, a JsonResponse is now returned if JSON
was requested, instead of the regular HTML content.

Resolves: #88376
Releases: master
Change-Id: I6be57fadaa0ddf83039fbdcc9186ef93d5a51158
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60453

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 91d5f80b
......@@ -1258,12 +1258,7 @@ return [
'addAllowedPaths' => '',
'debug' => false,
'compressionLevel' => 0,
'pageNotFound_handling' => '',
'pageNotFound_handling_statheader' => 'HTTP/1.0 404 Not Found',
'pageNotFound_handling_accessdeniedheader' => 'HTTP/1.0 403 Access denied',
'pageNotFoundOnCHashError' => true,
'pageUnavailable_handling' => '',
'pageUnavailable_handling_statheader' => 'HTTP/1.0 503 Service Temporarily Unavailable',
'pageUnavailable_force' => false,
'addRootLineFields' => '',
'checkFeUserPid' => true,
......
......@@ -377,27 +377,12 @@ FE:
compressionLevel:
type: int
description: 'Determines output compression of FE output. Makes output smaller but slows down the page generation depending on the compression level. Requires zlib in your PHP installation. Range 1-9, where 1 is least compression and 9 is greatest compression. ''true'' as value will set the compression based on the PHP default settings (usually 5). Suggested and most optimal value is 5.'
pageNotFound_handling:
type: text
description: '<p>How TYPO3 should handle requests for non-existing/accessible pages.</p> <dl><dt>empty (default)</dt><dd>The next visible page upwards in the page tree is shown.</dd> <dt>''true'' or ''1''</dt><dd>An error message is shown.</dd><dt>String</dt><dd>Static HTML file to show (reads content and outputs with correct headers), e.g. ''notfound.html'' or ''http://www.example.org/errors/notfound.html''.</dd> <dt>Prefix "REDIRECT:"</dt><dd> If prefixed with "REDIRECT:" it will redirect to the URL/script after the prefix.</dd><dt>Prefix "READFILE:"</dt><dd>If prefixed with "READFILE" then it will expect the remaining string to be a HTML file which will be read and outputted directly after having the marker "###CURRENT_URL###" substituted with REQUEST_URI and ###REASON### with reason text, for example: "READFILE:fileadmin/notfound.html".</dd> <dt>Prefix "USER_FUNCTION:"</dt><dd> If prefixed with "USER_FUNCTION:" a user function is called, e.g. "USER_FUNCTION:fileadmin/class.user_notfound.php:user_notFound->pageNotFound" where the file must contain a class "user_notFound" with a method "pageNotFound" inside with two parameters $param and $ref.</dd></dl>'
pageNotFound_handling_statheader:
type: text
description: 'If ''pageNotFound_handling'' is enabled, this string will always be sent as header before the actual handling. This applies to non-access-restriction related errors.'
pageNotFound_handling_accessdeniedheader:
type: text
description: 'If ''pageNotFound_handling'' is enabled, this string will always be sent as header before the actual handling. This applies to access-restricted related errors.'
pageNotFoundOnCHashError:
type: bool
description: 'If TRUE, a page not found call is made when cHash evaluation error occurs, otherwise caching is disabled and page output is displayed.'
pageUnavailable_handling:
type: text
description: '<p>How TYPO3 should handle requests when pages are unavailable due to system problems.</p><dl><dt>empty (default)</dt><dd>An error message is shown.</dd><dt>String</dt><dd>HTML file or URL to show (reads content and outputs with correct headers), e.g. ''unavailable.html'' or ''http://www.example.org/errors/unavailable.html''.</dd><dt>Prefix "REDIRECT:"</dt><dd>If prefixed "REDIRECT:" it will redirect to the URL/script after the prefix.</dd><dt>Prefix "READFILE:"</dt><dd>If prefixed with "READFILE:" then it will expect the remaining string to be a HTML file which will be read and outputted directly after having the marker "###CURRENT_URL###" substituted with REQUEST_URI and ###REASON### with reason text, for example: "READFILE:fileadmin/unavailable.html".</dd><dt>Prefix "USER_FUNCTION:"</dt><dd>If prefixed "USER_FUNCTION:" then it will call a user function, eg. "USER_FUNCTION:fileadmin/class.user_unavailable.php:user_unavailable->pageUnavailable" where the file must contain a class "user_unavailable" with a method "pageUnavailable" inside with two parameters $param and $ref. If the client matches <a href="#SYS-devIPmask">[SYS][devIPmask]</a>, this setting is ignored and the page is shown as normal.</dd></dl>'
pageUnavailable_handling_statheader:
type: text
description: 'If ''pageUnavailable_handling'' is enabled, this string will always be sent as header before the actual handling.'
pageUnavailable_force:
type: bool
description: 'If TRUE, pageUnavailable_handling is used for every frontend page. If the client matches <a href="#SYS-devIPmask">[SYS][devIPmask]</a>, the page is shown as normal. This is useful during temporary site maintenance.'
description: 'If TRUE, every frontend page is shown as "unavailable". If the client matches <a href="#SYS-devIPmask">[SYS][devIPmask]</a>, the page is shown as normal. This is useful during temporary site maintenance.'
addRootLineFields:
type: list
description: 'Comma-list of fields from the ''pages''-table. These fields are added to the select query for fields in the rootline.'
......
......@@ -1363,6 +1363,11 @@ The following constants have been set to protected:
The following global options are ignored:
* :php:`$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_accessdeniedheader']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling_statheader']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/saltedpasswords']['saltMethods']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['recursiveDomainSearch']`
......
.. include:: ../../Includes.txt
====================================================================
Breaking: #88376 - Removed obsolete "pageNotFound_handling" settings
====================================================================
See :issue:`88376`
Description
===========
The following global TYPO3 settings usually set within `LocalConfiguration.php` have been removed:
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_accessdeniedheader']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling']`
* :php:`$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling_statheader']`
These settings are effectively replaced by the error handling of the newly introduced Site Handling
which is more flexible and robust, and is used instead of these options when Site Handling was
enabled in TYPO3 v9. For TYPO3 v10 Site Handling is a requirement, making these options useless.
Impact
======
Setting any of the options will have no effect any more. Executing the Silent Upgrade Wizard
will remove the settings automatically.
Affected Installations
======================
Any TYPO3 installations having these settings overridden in `LocalConfiguration.php`
file of an installation.
Migration
=========
Access the install tool to automatically update the `LocalConfiguration.php` file and remove the
settings.
Ensure to set up Site Handling with proper error handlers. Avoid accessing these settings but
rather use the available `ErrorController` PHP class, when trying to manually trigger a 404/500
in the Frontend (e.g. custom plugin) instead.
.. index:: Frontend, LocalConfiguration, PartiallyScanned, ext:frontend
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\CSV\Modify;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
/**
* Functional test for the DataHandler
*/
......@@ -244,8 +246,8 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\CSV\
parent::deletePage();
$this->assertAssertionDataSet('deletePage');
$response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
$this->assertStringContainsString('PageNotFoundException', $response->getError());
$response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
$this->assertEquals(404, $response->getStatusCode());
}
/**
......
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\ForeignField\Modify;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
/**
* Functional test for the DataHandler
*/
......@@ -311,8 +313,8 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\Fore
parent::deletePage();
$this->assertAssertionDataSet('deletePage');
$response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
$this->assertStringContainsString('PageNotFoundException', $response->getError());
$response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
$this->assertEquals(404, $response->getStatusCode());
}
/**
......
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Modify;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
/**
* Functional test for the DataHandler
*/
......@@ -484,8 +486,8 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\A
parent::deletePage();
$this->assertAssertionDataSet('deletePage');
$response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, false);
$this->assertStringContainsString('PageNotFoundException', $response->getError());
$response = $this->executeFrontendRequest((new InternalRequest())->withPageId(self::VALUE_PageId));
$this->assertEquals(404, $response->getStatusCode());
}
/**
......
......@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
*/
use ExtbaseTeam\BlogExample\Domain\Repository\TtContentRepository;
use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
use TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase;
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -496,11 +495,6 @@ class TranslatedSiteContentTest extends AbstractDataHandlerActionTestCase
]
);
if ($statusCode === 404) {
$this->expectExceptionCode(1518472189);
$this->expectException(PageNotFoundException::class);
}
$response = $this->executeFrontendRequest(
new InternalRequest('https://website.local/de/?id=' . static::VALUE_PageId)
);
......
......@@ -23,7 +23,7 @@ use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerNotConfiguredException;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -52,12 +52,7 @@ class ErrorController
if ($errorHandler instanceof PageErrorHandlerInterface) {
return $errorHandler->handlePageError($request, $message, $reasons);
}
return $this->handlePageError(
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling'],
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling_statheader'],
$message,
$reasons
);
return $this->handleDefaultError($request, 500, $message ?: 'Page is unavailable');
}
/**
......@@ -76,15 +71,11 @@ class ErrorController
if ($errorHandler instanceof PageErrorHandlerInterface) {
return $errorHandler->handlePageError($request, $message, $reasons);
}
if (!$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
try {
return $this->handleDefaultError($request, 404, $message);
} catch (\RuntimeException $e) {
throw new PageNotFoundException($message, 1518472189);
}
return $this->handlePageError(
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'],
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader'],
$message,
$reasons
);
}
/**
......@@ -95,6 +86,7 @@ class ErrorController
* @param string $message
* @param array $reasons
* @return ResponseInterface
* @throws PageNotFoundException
*/
public function accessDeniedAction(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
{
......@@ -102,12 +94,11 @@ class ErrorController
if ($errorHandler instanceof PageErrorHandlerInterface) {
return $errorHandler->handlePageError($request, $message, $reasons);
}
return $this->handlePageError(
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'],
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_accessdeniedheader'],
$message,
$reasons
);
try {
return $this->handleDefaultError($request, 403, $message);
} catch (\RuntimeException $e) {
throw new PageNotFoundException($message, 1518472195);
}
}
/**
......@@ -118,181 +109,7 @@ class ErrorController
*/
protected function isPageUnavailableHandlerConfigured(): bool
{
return
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageUnavailable_handling']
&& !GeneralUtility::cmpIP(
GeneralUtility::getIndpEnv('REMOTE_ADDR'),
$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
)
;
}
/**
* Generic error page handler.
*
* @param mixed $errorHandler See docs of ['FE']['pageNotFound_handling'] and ['FE']['pageUnavailable_handling'] for all possible values
* @param string $header If set, this is passed directly to the PHP function, header()
* @param string $reason If set, error messages will also mention this as the reason for the page-not-found.
* @param array $pageAccessFailureReasons
* @return ResponseInterface
* @throws \RuntimeException
*/
protected function handlePageError($errorHandler, string $header = '', string $reason = '', array $pageAccessFailureReasons = []): ResponseInterface
{
$response = null;
$content = '';
// Simply boolean; Just shows TYPO3 error page with reason:
if (is_bool($errorHandler) || strtolower($errorHandler) === 'true' || (string)$errorHandler === '1') {
$content = GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
'Page Not Found',
'The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . $reason : '')
);
} elseif (GeneralUtility::isFirstPartOfStr($errorHandler, 'USER_FUNCTION:')) {
$funcRef = trim(substr($errorHandler, 14));
$params = [
'currentUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
'reasonText' => $reason,
'pageAccessFailureReasons' => $pageAccessFailureReasons
];
try {
$content = GeneralUtility::callUserFunction($funcRef, $params, $this);
} catch (\Exception $e) {
throw new \RuntimeException('Error: 404 page by USER_FUNCTION "' . $funcRef . '" failed.', 1518472235, $e);
}
} elseif (GeneralUtility::isFirstPartOfStr($errorHandler, 'READFILE:')) {
$readFile = GeneralUtility::getFileAbsFileName(trim(substr($errorHandler, 9)));
if (@is_file($readFile)) {
$content = str_replace(
[
'###CURRENT_URL###',
'###REASON###'
],
[
GeneralUtility::getIndpEnv('REQUEST_URI'),
htmlspecialchars($reason)
],
file_get_contents($readFile)
);
} else {
throw new \RuntimeException('Configuration Error: 404 page "' . $readFile . '" could not be found.', 1518472245);
}
} elseif (GeneralUtility::isFirstPartOfStr($errorHandler, 'REDIRECT:')) {
$response = new RedirectResponse(substr($errorHandler, 9));
} elseif ($errorHandler !== '') {
// Check if URL is relative
$urlParts = parse_url($errorHandler);
// parse_url could return an array without the key "host", the empty check works better than strict check
if (empty($urlParts['host'])) {
$urlParts['host'] = GeneralUtility::getIndpEnv('HTTP_HOST');
if ($errorHandler[0] === '/') {
$errorHandler = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . $errorHandler;
} else {
$errorHandler = GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . $errorHandler;
}
$checkBaseTag = false;
} else {
$checkBaseTag = true;
}
// Check recursion
if ($errorHandler === GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) {
$reason = $reason ?: 'Page cannot be found.';
$reason .= LF . LF . 'Additionally, ' . $errorHandler . ' was not found while trying to retrieve the error document.';
throw new \RuntimeException(nl2br(htmlspecialchars($reason)), 1518472252);
}
// Prepare headers
$requestHeaders = [
'User-agent' => GeneralUtility::getIndpEnv('HTTP_USER_AGENT'),
'Referer' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')
];
$report = [];
$res = GeneralUtility::getUrl($errorHandler, 1, $requestHeaders, $report);
if ((int)$report['error'] !== 0 && (int)$report['error'] !== 200) {
throw new \RuntimeException('Failed to fetch error page "' . $errorHandler . '", reason: ' . $report['message'], 1518472257);
}
if ($res === false) {
// Last chance -- redirect
$response = new RedirectResponse($errorHandler);
} else {
// Header and content are separated by an empty line
list($returnedHeaders, $content) = explode(CRLF . CRLF, $res, 2);
$content .= CRLF;
// Forward these response headers to the client
$forwardHeaders = [
'Content-Type:'
];
$headerArr = preg_split('/\\r|\\n/', $returnedHeaders, -1, PREG_SPLIT_NO_EMPTY);
foreach ($headerArr as $headerLine) {
foreach ($forwardHeaders as $h) {
if (preg_match('/^' . $h . '/', $headerLine)) {
$header .= CRLF . $headerLine;
}
}
}
// Put <base> if necessary
if ($checkBaseTag) {
// If content already has <base> tag, we do not need to do anything
if (false === stristr($content, '<base ')) {
// Generate href for base tag
$base = $urlParts['scheme'] . '://';
if ($urlParts['user'] != '') {
$base .= $urlParts['user'];
if ($urlParts['pass'] != '') {
$base .= ':' . $urlParts['pass'];
}
$base .= '@';
}
$base .= $urlParts['host'];
// Add path portion skipping possible file name
$base .= preg_replace('/(.*\\/)[^\\/]*/', '${1}', $urlParts['path']);
// Put it into content (generate also <head> if necessary)
$replacement = LF . '<base href="' . htmlentities($base) . '" />' . LF;
if (stristr($content, '<head>')) {
$content = preg_replace('/(<head>)/i', '\\1' . $replacement, $content);
} else {
$content = preg_replace('/(<html[^>]*>)/i', '\\1<head>' . $replacement . '</head>', $content);
}
}
}
}
} else {
$content = GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
'Page Not Found',
$reason ? 'Reason: ' . $reason : 'Page cannot be found.'
);
}
if (!$response) {
$response = new HtmlResponse($content);
}
return $this->applySanitizedHeadersToResponse($response, $header);
}
/**
* Headers which have been requested, will be added to the response object.
* If a header is part of the HTTP Response code, the response object will be annotated as well.
*
* @param ResponseInterface $response
* @param string $headers
* @return ResponseInterface
*/
protected function applySanitizedHeadersToResponse(ResponseInterface $response, string $headers): ResponseInterface
{
if (!empty($headers)) {
$headerArr = preg_split('/\\r|\\n/', $headers, -1, PREG_SPLIT_NO_EMPTY);
foreach ($headerArr as $headerLine) {
if (strpos($headerLine, 'HTTP/') === 0 && strpos($headerLine, ':') === false) {
list($protocolVersion, $statusCode, $reasonPhrase) = explode(' ', $headerLine, 3);
list(, $protocolVersion) = explode('/', $protocolVersion, 2);
$response = $response
->withProtocolVersion((int)$protocolVersion)
->withStatus($statusCode, $reasonPhrase);
} else {
list($headerName, $value) = GeneralUtility::trimExplode(':', $headerLine, 2);
$response = $response->withHeader($headerName, $value);
}
}
}
return $response;
return !GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
}
/**
......@@ -314,4 +131,24 @@ class ErrorController
}
return null;
}
/**
* Ensures that a response object is created as a "fallback" when no error handler is configured.
*
* @param ServerRequestInterface $request
* @param int $statusCode
* @param string $reason
* @return ResponseInterface
*/
protected function handleDefaultError(ServerRequestInterface $request, int $statusCode, string $reason = ''): ResponseInterface
{
if (strpos($request->getHeaderLine('Accept'), 'application/json') !== false) {
return new JsonResponse(['reason' => $reason], $statusCode);
}
$content = GeneralUtility::makeInstance(ErrorPageController::class)->errorAction(
'Page Not Found',
'The page did not exist or was inaccessible.' . ($reason ? ' Reason: ' . $reason : '')
);
return new HtmlResponse($content, $statusCode);
}
}
......@@ -1129,10 +1129,6 @@ class TypoScriptFrontendController implements LoggerAwareInterface
* Exceptions may be thrown for DOKTYPE_SPACER and not loadable page records
* or root lines.
*
* If $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] is set,
* instead of throwing an exception it's handled by a page unavailable
* handler.
*
* May set or update this properties:
*
* @see TypoScriptFrontendController::$id
......
......@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Rendering;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
......@@ -676,10 +675,6 @@ class LocalizedSiteContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional
]
);
if ($statusCode === 404) {
$this->expectExceptionCode(1518472189);
$this->expectException(PageNotFoundException::class);
}
$response = $this->executeFrontendRequest(
new InternalRequest('https://website.local/de/?id=' . static::VALUE_PageId)
);
......@@ -723,6 +718,7 @@ class LocalizedSiteContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional
$this->assertEquals($fallbackChain, $responseStructure->getScopePath('languageInfo/fallbackChain'), 'fallbackChain does not match');
$this->assertEquals($overlayMode, $responseStructure->getScopePath('languageInfo/overlayType'), 'language overlayType does not match');
}
$this->assertEquals($statusCode, $response->getStatusCode());
}
public function contentOnPartiallyTranslatedPageDataProvider(): array
......
......@@ -106,17 +106,17 @@ abstract class AbstractLocalizedPagesTestCase extends AbstractTestCase
/**
* @param string $url
* @param string $exception
* @param int $exception
*/
protected function assertException(string $url, string $exception): void
protected function assertResponseStatusCode(string $url, int $statusCode): void
{
$this->setUpFrontendRootPage(
1000,
['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']
);
$this->expectException($exception);
$this->executeFrontendRequest(new InternalRequest($url), $this->internalRequestContext);
$response = $this->executeFrontendRequest(new InternalRequest($url), $this->internalRequestContext);
static::assertSame(404, $response->getStatusCode());
}
/**
......
......@@ -34,7 +34,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRenderin
* Calling home page in DE-CH renders page in DE as defined in the fallback chain
*
* Calling "headquarter" page in EN renders page in EN
* Calling "headquarter" page in DE throws a PageNotFoundException because no fallback chain is configured
* Calling "headquarter" page in DE returns a 404 response because no fallback chain is configured
* Calling "headquarter" page in DE-CH renders page in EN
*/
class ScenarioATest extends AbstractLocalizedPagesTestCase
......
......@@ -16,8 +16,6 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\LocalizedPageRenderin
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
/**
* Scenario prerequisites:
* Site configuration has localizations
......@@ -31,11 +29,11 @@ use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
*
* Scenario expectations:
* Calling home page in EN renders page in EN
* Calling home page in DE throws a PageNotFoundException because no fallback chain is configured
* Calling home page in DE returns a 404 response because no fallback chain is configured
* Calling home page in DE-CH renders page in EN as defined in the fallback chain