Issue Bug Closed

#106060Missing Lifetime in cachetag generation

Pascal Geldmacher 02/03/25, 09:34 updated 12/02/25, 14:26

Description

The ContentObjectRenderer creates in the render function cacheTags, but don’t set the lifetime which can leads to an error
gmdate(): Argument #2 ($timestamp) must be of type ?int, float given because it’s use the PHP_MAX_INT value.
At the moment this onyl happens if I use the yoast preview in the backend context.

I have a TypoScript snippet which creates an cache entry:

    cache {
        lifetime = unlimited
        tags = tag_typoscript
    }

Here is the part of the ContentObjectRenderer where the cacheTag does not get the lifetime:

  // Store cache
        if ($cacheConfiguration !== null && $this->getRequest()->getAttribute('frontend.cache.instruction')->isCachingAllowed()) {
            $key = $this->calculateCacheKey($cacheConfiguration);
            if (!empty($key)) {
                $cacheFrontend = GeneralUtility::makeInstance(CacheManager::class)->getCache('hash');
                $tags = $this->calculateCacheTags($cacheConfiguration);
                $lifetime = $this->calculateCacheLifetime($cacheConfiguration);
                $cachedData = [
                    'content' => $content,
                    'cacheTags' => $tags,
                ];
                $cacheFrontend->set($key, $cachedData, $tags, $lifetime);
                $this->getRequest()->getAttribute('frontend.cache.collector')->addCacheTags(
                    ...array_map(fn(string $tag) => new CacheTag($tag), $tags)
                );
            }
        }

Reviews 2

History 36

  1. Pascal Geldmacher commented 02/03/25, 12:09

    The problem only happens if the feature frontend.cache.autoTagging is disabled.

  2. Gerrit Code Review pushed patch set 1 for main to change 88100 status New Under Review 02/08/25, 11:55

  3. Gerrit Code Review pushed patch set 2 for main to change 88100 02/08/25, 20:41

  4. Gerrit Code Review pushed patch set 1 for 13.4 to change 88121 02/09/25, 18:30

  5. Sascha Nowak commented and changed status Under Review Resolved done 0 % 100 % 02/09/25, 18:50

    Applied in changeset commit:ae09ed5db73ab7b209e4631062109acfb06dc031.

  6. Benni Mack changed status Resolved Closed 12/02/25, 14:26