mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-21 22:16:11 +01:00
Fix wrong detection of Page Cache timeout (TTL) (#20)
Use the earliest instead of latest timeout. Extend tests to cover the bug. Relates: #10506
This commit is contained in:
parent
a122f515d8
commit
d6d3330bd3
2 changed files with 51 additions and 1 deletions
|
@ -120,7 +120,7 @@ class PageCacheTimeout implements SingletonInterface
|
|||
$newTimeout <= $now
|
||||
|| (
|
||||
$this->timeout instanceof DateTimeImmutable
|
||||
&& $this->timeout >= $newTimeout
|
||||
&& $this->timeout <= $newTimeout
|
||||
)
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -174,6 +174,56 @@ class CacheTest extends AbstractTestCase
|
|||
self::assertCacheHeaders($end, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function usesEarliestTimeout(): void
|
||||
{
|
||||
$end = (new DateTimeImmutable('now', new DateTimeZone('UTC')))->modify('+2 hours');
|
||||
|
||||
(new PhpDataSet())->import([
|
||||
'tx_events_domain_model_event' => [
|
||||
[
|
||||
'uid' => '1',
|
||||
'pid' => '2',
|
||||
'title' => 'Test Event 1',
|
||||
],
|
||||
[
|
||||
'uid' => '2',
|
||||
'pid' => '2',
|
||||
'title' => 'Test Event 2',
|
||||
],
|
||||
],
|
||||
'tx_events_domain_model_date' => [
|
||||
[
|
||||
'pid' => '2',
|
||||
'event' => '1',
|
||||
'start' => $end->format('U'),
|
||||
'end' => '0',
|
||||
],
|
||||
[
|
||||
'pid' => '2',
|
||||
'event' => '2',
|
||||
'start' => $end->modify('+2 hours')->format('U'),
|
||||
'end' => '0',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->executeFrontendRequest($this->getRequestWithSleep([
|
||||
'plugin.' => [
|
||||
'tx_events.' => [
|
||||
'settings.' => [
|
||||
'upcoming' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
]));
|
||||
|
||||
self::assertSame(200, $response->getStatusCode());
|
||||
self::assertCacheHeaders($end, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue