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 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-10-22 15:47:19 +02:00
1 parent ebc9925304
commit 20225ad9e3
1 file changed
+16 -6
@@ -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)
{