Skip to content

Commit ad3d93a

Browse files
saschanowaklolli42
authored andcommitted
[BUGFIX] Correct cache lifetime calculation for pages
Page cache lifetime is calculated differently from other records. The current implementation in ContentObjectRenderer doesn’t account for this difference, resulting in incorrect lifetime values. It is ok to skip lifetime calculation for pages table records in ContentObjectRenderer, details are added as inline code comment. Resolves: #107097 Releases: main, 13.4 Change-Id: I565b46c6efd7cfab148dc51187e08dd22d46a0ef Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/92026 Reviewed-by: Christian Kuhn <[email protected]> Tested-by: Garvin Hicking <[email protected]> Reviewed-by: Sascha Nowak <[email protected]> Tested-by: Christian Kuhn <[email protected]> Tested-by: Sascha Nowak <[email protected]> Reviewed-by: Garvin Hicking <[email protected]> Tested-by: core-ci <[email protected]>
1 parent 23dc2ea commit ad3d93a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,14 @@ public function start($data, $table = ''): void
516516
$this->eventDispatcher->dispatch(new AfterContentObjectRendererInitializedEvent($this));
517517

518518
$autoTagging = $this->features->isFeatureEnabled('frontend.cache.autoTagging');
519-
if (is_array($this->data) && $this->currentRecord !== '' && $autoTagging) {
519+
if (is_array($this->data) && $this->currentRecord !== '' && $autoTagging && $this->table !== 'pages') {
520+
// Page lifetime for the requested page is calculated in RequestHandler, taking
521+
// cache_period and TypoScript into account.
522+
// When start() is called here, it can be the requested page record, which is handled
523+
// already, OR it is a page record *used* on this page, for instance from a menu rendering.
524+
// In the latter case, we do *not* want to reduce the lifetime of the rendered page down
525+
// to the cache_period of that content related page record. We can thus skip 'pages' records
526+
// here altogether.
520527
$lifetime = $this->cacheLifetimeCalculator->calculateLifetimeForRow($this->table, $this->data);
521528
$cacheTags = [
522529
sprintf('%s_%s', $this->table, ($this->data['uid'] ?? 0)),

0 commit comments

Comments
 (0)