mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-21 16:56:11 +01:00
Properly trigger 404 if date of unavailable event is requested (#39)
This commit is contained in:
parent
27ee70d0cf
commit
82df4ded99
9 changed files with 113 additions and 1 deletions
|
@ -21,8 +21,13 @@ namespace Wrm\Events\Controller;
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Exception\Page\PageNotFoundException;
|
||||
use TYPO3\CMS\Core\Http\ImmediateResponseException;
|
||||
use TYPO3\CMS\Core\Http\PropagateResponseException;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\Controller\ErrorController;
|
||||
use Wrm\Events\Caching\CacheManager;
|
||||
|
||||
class AbstractController extends ActionController
|
||||
|
@ -66,4 +71,21 @@ class AbstractController extends ActionController
|
|||
|
||||
return $view;
|
||||
}
|
||||
|
||||
protected function trigger404(string $message): void
|
||||
{
|
||||
$errorController = GeneralUtility::makeInstance(ErrorController::class);
|
||||
|
||||
if (class_exists(ImmediateResponseException::class)) {
|
||||
throw new ImmediateResponseException(
|
||||
$errorController->pageNotFoundAction($GLOBALS['TYPO3_REQUEST'], $message),
|
||||
1695881164
|
||||
);
|
||||
}
|
||||
|
||||
throw new PropagateResponseException(
|
||||
$errorController->pageNotFoundAction($this->request, $message),
|
||||
1695881170
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Wrm\Events\Controller;
|
|||
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
|
||||
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
||||
use TYPO3\CMS\Extbase\Service\ExtensionService;
|
||||
use Throwable;
|
||||
use Wrm\Events\Domain\Model\Date;
|
||||
use Wrm\Events\Domain\Model\Dto\DateDemandFactory;
|
||||
use Wrm\Events\Domain\Repository\CategoryRepository;
|
||||
|
@ -155,6 +156,12 @@ class DateController extends AbstractController
|
|||
*/
|
||||
public function showAction(Date $date): void
|
||||
{
|
||||
try {
|
||||
$date->getEvent();
|
||||
} catch (Throwable $e) {
|
||||
$this->trigger404('No event found for requested date.');
|
||||
}
|
||||
|
||||
$this->view->assign('date', $date);
|
||||
}
|
||||
|
||||
|
|
31
Documentation/Changelog/3.5.1.rst
Normal file
31
Documentation/Changelog/3.5.1.rst
Normal file
|
@ -0,0 +1,31 @@
|
|||
3.5.1
|
||||
=====
|
||||
|
||||
Breaking
|
||||
--------
|
||||
|
||||
Nothing
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Nothing
|
||||
|
||||
Fixes
|
||||
-----
|
||||
|
||||
* Properly trigger 404 if a date is requested where event is not available.
|
||||
This might happen if an event is set to hidden.
|
||||
The date record is still available and can be requested.
|
||||
But the event is missing, which in turn should make dates also unavailable.
|
||||
This situation is now properly handled and will result in a 404.
|
||||
|
||||
Tasks
|
||||
-----
|
||||
|
||||
Nothing
|
||||
|
||||
Deprecation
|
||||
-----------
|
||||
|
||||
Nothing
|
|
@ -9,3 +9,9 @@ Remove fetching cached page stage from body from tests
|
|||
|
||||
We have different assertions based on TYPO3 version, due to how TYPO3 exposes the info.
|
||||
We can remove the condition with its content once we drop v10.
|
||||
|
||||
Remove condition for page not found handling
|
||||
--------------------------------------------
|
||||
|
||||
The :php:`AbstractController->trigger404()` method has a condition to handle 404 differently for TYPO3 v10.
|
||||
The condition can be removed.
|
||||
|
|
|
@ -69,6 +69,11 @@ abstract class AbstractFunctionalTestCase extends FunctionalTestCase
|
|||
]);
|
||||
|
||||
ArrayUtility::mergeRecursiveWithOverrule($this->configurationToUseInTestInstance, [
|
||||
'FE' => [
|
||||
'cacheHash' => [
|
||||
'enforceValidation' => false,
|
||||
],
|
||||
],
|
||||
'GFX' => [
|
||||
'processor_enabled' => true,
|
||||
'processor_path' => '/usr/bin/',
|
||||
|
|
|
@ -153,6 +153,23 @@ class DatesTest extends AbstractFunctionalTestCase
|
|||
self::assertStringContainsString('Event 9', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returns404IfEventIsHidden(): void
|
||||
{
|
||||
$this->importCSVDataSet(__DIR__ . '/DatesTestFixtures/Returns404IfEventIsHidden.csv');
|
||||
|
||||
$request = new InternalRequest();
|
||||
$request = $request->withPageId(1);
|
||||
$request = $request->withQueryParameters([
|
||||
'tx_events_dateshow[date]' => '1',
|
||||
]);
|
||||
$response = $this->executeFrontendRequest($request);
|
||||
|
||||
self::assertSame(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
tt_content
|
||||
,uid,pid,CType,list_type,header
|
||||
,1,1,list,events_dateshow,Singleview
|
||||
tx_events_domain_model_event
|
||||
,uid,pid,title,hidden
|
||||
,1,2,"Event 1 starts before search, ends before search",1
|
||||
tx_events_domain_model_date
|
||||
,uid,pid,event,start,end
|
||||
,1,2,1,1676419200,1676484000
|
Can't render this file because it has a wrong number of fields in line 2.
|
|
@ -9,7 +9,7 @@ $EM_CONF['events'] = [
|
|||
'state' => 'alpha',
|
||||
'createDirs' => '',
|
||||
'clearCacheOnLoad' => 0,
|
||||
'version' => '3.5.0',
|
||||
'version' => '3.5.1',
|
||||
'constraints' => [
|
||||
'depends' => [
|
||||
'typo3' => '10.4.00-11.5.99',
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Instantiated class TYPO3\\\\CMS\\\\Core\\\\Http\\\\PropagateResponseException not found\\.$#"
|
||||
count: 1
|
||||
path: Classes/Controller/AbstractController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$request of method TYPO3\\\\CMS\\\\Frontend\\\\Controller\\\\ErrorController\\:\\:pageNotFoundAction\\(\\) expects Psr\\\\Http\\\\Message\\\\ServerRequestInterface, TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Request given\\.$#"
|
||||
count: 1
|
||||
path: Classes/Controller/AbstractController.php
|
||||
|
||||
-
|
||||
message: "#^Throwing object of an unknown class TYPO3\\\\CMS\\\\Core\\\\Http\\\\PropagateResponseException\\.$#"
|
||||
count: 1
|
||||
path: Classes/Controller/AbstractController.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method typoLink_URL\\(\\) on TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\|null\\.$#"
|
||||
count: 1
|
||||
|
|
Loading…
Reference in a new issue