mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-04 20:06:09 +01:00
Trigger 404 for date show action without date
This commit is contained in:
parent
8eb784cbb3
commit
6bced3c314
5 changed files with 42 additions and 1 deletions
|
@ -70,6 +70,11 @@ abstract class AbstractController extends ActionController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will throw exception to trigger 404.
|
||||||
|
*
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
protected function trigger404(string $message): void
|
protected function trigger404(string $message): void
|
||||||
{
|
{
|
||||||
throw new PropagateResponseException(
|
throw new PropagateResponseException(
|
||||||
|
|
|
@ -105,8 +105,12 @@ final class DateController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Extbase\IgnoreValidation(['value' => 'date'])]
|
#[Extbase\IgnoreValidation(['value' => 'date'])]
|
||||||
public function showAction(Date $date): ResponseInterface
|
public function showAction(?Date $date = null): ResponseInterface
|
||||||
{
|
{
|
||||||
|
if ($date === null) {
|
||||||
|
$this->trigger404('No date given.');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$date->getEvent();
|
$date->getEvent();
|
||||||
} catch (Throwable) {
|
} catch (Throwable) {
|
||||||
|
|
|
@ -33,6 +33,11 @@ Features
|
||||||
The field no longer has a limitation.
|
The field no longer has a limitation.
|
||||||
The field is now stored as `text` instead of `varchar`.
|
The field is now stored as `text` instead of `varchar`.
|
||||||
|
|
||||||
|
* Deliver 404 on date show action without a given date.
|
||||||
|
|
||||||
|
This previously triggered an TYPO3 Exception.
|
||||||
|
We now handle the situation and trigger a TYPO3 404.
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,19 @@ final class DatesTest extends AbstractFrontendTestCase
|
||||||
self::assertStringContainsString('Event 9', $html);
|
self::assertStringContainsString('Event 9', $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function returns404IfNoDateIsGiven(): void
|
||||||
|
{
|
||||||
|
$this->importPHPDataSet(__DIR__ . '/DatesTestFixtures/Returns404IfNoDateIsGiven.php');
|
||||||
|
|
||||||
|
$request = new InternalRequest('https://example.com/');
|
||||||
|
$request = $request->withPageId(1);
|
||||||
|
|
||||||
|
$response = $this->executeFrontendSubRequest($request);
|
||||||
|
|
||||||
|
self::assertSame(404, $response->getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function returns404IfEventIsHidden(): void
|
public function returns404IfEventIsHidden(): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'tt_content' => [
|
||||||
|
0 => [
|
||||||
|
'uid' => '1',
|
||||||
|
'pid' => '1',
|
||||||
|
'CType' => 'events_dateshowtest',
|
||||||
|
'header' => 'Singleview',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
Loading…
Reference in a new issue