From 20225ad9e35ca6380c1c7757b0fb71db119e7313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 22 Oct 2026 15:47:19 +0200 Subject: [PATCH] fix: /reiseinformationen/ without a travel info answers 404 instead of 500 The page holds only the travel info plugin, whose default action required a travel info: opened without a slug or code it failed with "Required argument travelInfo is not set" (TYPO3 10 did the same). The argument is optional now and its absence gives the same 404 as an unknown slug or travel code (notFound(), shared with travelCodeAction). Co-Authored-By: Claude Opus 5.5 --- .../Controller/TravelinfoController.php | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/ep_products/Classes/Controller/TravelinfoController.php b/packages/ep_products/Classes/Controller/TravelinfoController.php index 8e2e44b..4d640fe 100644 --- a/packages/ep_products/Classes/Controller/TravelinfoController.php +++ b/packages/ep_products/Classes/Controller/TravelinfoController.php @@ -45,25 +45,35 @@ class TravelinfoController extends ActionController // return 404 in case no travel info is available as last resort if (null === $travelInfo) { - $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( - $this->request, - 'Reiseinformationen nicht gefunden' - ); - throw new ImmediateResponseException($response, 1731071856); + $this->notFound(); } $this->handleRequest($travelCode, $travelInfo); return $this->htmlResponse(); } - public function travelInfoAction(Travelinfo $travelInfo): ResponseInterface + public function travelInfoAction(?Travelinfo $travelInfo = null): ResponseInterface { + // the page itself (/reiseinformationen/) without a travel info or code + if (null === $travelInfo) { + $this->notFound(); + } + $travelCode = $travelInfo->getTravelCode(); $this->handleRequest($travelCode, $travelInfo); return $this->htmlResponse(); } + private function notFound(): never + { + $response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction( + $this->request, + 'Reiseinformationen nicht gefunden' + ); + throw new ImmediateResponseException($response, 1731071856); + } + private function handleRequest(string $travelCode, Travelinfo $travelInfo) {