Issue Bug Closed

#102892RuntimeException when using redirects with record link targets

Christian Gebing 01/22/24, 18:21 updated 12/02/25, 14:33

Description

I get the following exception for redirects with record links targets after the site is stored in the cache:

(1/1) #1666513645 RuntimeException

Setup array has not been initialized. This happens in cached Frontend scope where full TypoScript is not needed by the system.
Steps to reproduce:
  1. Flush caches via the maintanance tool
  2. Add a new redirect with a record link target (e.g. t3://record?identifier=example&uid=1)
  3. Follow the redirect
  4. Open the start page or any other page on the current site
  5. Attempt to follow the redirect again

Tested on a minimal TYPO3 ddev setup: https://github.com/cgebing/typo3_record_link_test

Reviews 4

Files 2

History 2225

  1. Armin Vieweg commented <span data-processor="relativetime" data-value="2024-03-21T13:53:12+00:00" > 03/21/24, 13:53 </span>

    I can reconstruct this issue.
    It disappears, when clearing the frontend cache, then the redirects work as expected.

    But as soon as I call the front page (the first page in rootLine, which contains the TypoScript setup) and this page gets cached, the redirect break, with the exception from above.

    I tried several TYPO3 versions. This issue seems to occure since 12.4.2. In 12.4.1 I am not able to reconstruct the issue, by calling the first page in rootLine (the front page). There, the redirections always work.

  2. Armin Vieweg commented <span data-processor="relativetime" data-value="2024-03-21T15:53:04+00:00" > 03/21/24, 15:53 </span>

    A quick fix is, to disable caching on the first page in rootLine, with e.g.

    # Quick fix for https://forge.typo3.org/issues/102892
    [traverse(page, "uid") == 1]
    config.no_cache = 1
    [end]

    Absolutely not ideal or recommended, but this solves the issue, which only occures when the first page is being cached.

  3. Armin Vieweg commented <span data-processor="relativetime" data-value="2024-03-21T16:49:18+00:00" > 03/21/24, 16:49 </span>

    I also found the commit, which causes the issue:
    https://git.typo3.org/typo3/typo3/-/commit/bd4980f237bf844939b959d0a83909aa7a44b0e0

    The issue only occures when the feature toggle “Security: frontend enforce content security policy” security.frontend.enforceContentSecurityPolicy is disabled.

  4. Benni Mack commented <span data-processor="relativetime" data-value="2024-03-21T22:40:20+00:00" > 03/21/24, 22:40 </span>

    Some more notes:

    This is related to a fully cached page not having TypoScript anymore, see another issue / bugfix which happened in adminpanel on a fully cached page:

    https://review.typo3.org/c/Packages/TYPO3.CMS/+/82396

  5. Armin Vieweg commented <span data-processor="relativetime" data-value="2024-04-03T10:04:07+00:00" > 04/03/24, 10:04 </span>

    @ohader So, when CSP is on the page cache does not work anymore? Sounds a little bit like that.

    @benni Caching and providing the rendered Typoscript configuration, could solve this, maybe?

    Or the redirect Middleware must get enabled to parse the Typoscript, when being triggered and when the target starts with “t3:”.

    But maybe there are other edge cases, like redirects, which require the parsed Typoscript config.

  6. Ole Trenner commented <span data-processor="relativetime" data-value="2024-10-02T19:34:42+00:00" > 10/02/24, 19:34 </span>

    We are currently running into the same issue. Has there been any progress in fixing this? Or are there approaches to prevent the issue from happening? Thanks!

  7. Ramon Zöllner commented <span data-processor="relativetime" data-value="2024-10-04T11:32:48+00:00" > 10/04/24, 11:32 </span>

    We also ran into this issue with redirects to news records.
    All redirects to news records result in a 503.

    As a workaround we patched frontend/Classes/Typolink/DatabaseRecordLinkBuilder, catching the runtime exception and force generating the full typoscript.

    This solution seems less then ideal to me as it handles the issue downstream and also circumvents caching.

  8. Bernhard Eckl commented <span data-processor="relativetime" data-value="2024-11-18T12:10:20+00:00" > 11/18/24, 12:10 </span>

    Same here when linking to records.
    @ramon_z would you share your solution please?

  9. Ramon Zöllner commented and changed attached record-linkbuilder-missing-typoscript-fix.diff <span data-processor="relativetime" data-value="2024-11-20T10:57:48+00:00" > 11/20/24, 10:57 </span>

    @klodeckl sure. I appended the patch.

  10. Torben Hansen commented <span data-processor="relativetime" data-value="2024-11-20T13:52:11+00:00" > 11/20/24, 13:52 </span>

    @ramon_z Note, that the patch only provides a workaround for TYPO3 v12. I documented the whole topic in #105648 and discussed it with members of the core team, so we at some point can provide a core bugfix for the isssue.

  11. J. Peter M. Schuler commented <span data-processor="relativetime" data-value="2024-11-29T09:09:20+00:00" > 11/29/24, 09:09 </span>

    FWIW: This affects Page Error Handler as well – if you site config configure e.g. 404 handling with “Show content from page” and select a page it will have a setting like t3://page?uid=41140 Thus, running into the same problem.-
    -Current situation is that all 404s are now 503 :-/

    If you have a Page Error Handler pointing to a page using record handler, the patch in #14 doesn’t resolve this.
    Will look into that

  12. Torben Hansen commented <span data-processor="relativetime" data-value="2024-11-29T09:15:24+00:00" > 11/29/24, 09:15 </span>

    @jpmschuler I can not confirm, that this affects the page error handler and the t3:// syntax in that place. Please check, if the target 404 page contains any links handled by a record handler.

  13. Bernhard Eckl commented <span data-processor="relativetime" data-value="2024-11-29T09:18:11+00:00" > 11/29/24, 09:18 </span>

    Ramon Zöllner wrote in #note-14:
    > @klodeckl sure. I appended the patch.

    Thank you!

  14. J. Peter M. Schuler commented <span data-processor="relativetime" data-value="2024-11-29T09:22:20+00:00" > 11/29/24, 09:22 </span>

    Torben Hansen wrote in #note-17:
    > @jpmschuler I can not confirm, that this affects the page error handler and the t3:// syntax in that place. Please check, if the target 404 page contains any links handled by a record handler.
    Just one text-only element, but the page itself uses some complex fluid for the navigation with custom f:typolink; then it must be that.
    Sorry, thought as the 404 page itself is properly cached and has no problems, it is the error handler itself, not the target page.

    Thx for the pointer, sry for the hassle.

  15. Torben Hansen commented and changed status New Accepted assigned to Torben Hansen <span data-processor="relativetime" data-value="2024-12-25T17:55:19+00:00" > 12/25/24, 17:55 </span>

    In general, the record link calculation should be decoupled from TypoScript as a dependency, since this not only fails for the redirect service but also in some places in backend context.

    I spent some hours on debugging und came up with the following patches, which I also will submit to gerrit.

    Bugfix for v13

    Index: typo3/sysext/redirects/Classes/Service/RedirectService.php
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/typo3/sysext/redirects/Classes/Service/RedirectService.php b/typo3/sysext/redirects/Classes/Service/RedirectService.php
    --- a/typo3/sysext/redirects/Classes/Service/RedirectService.php    (revision e20f00fbd1e29c1c4b58439e2e81434bdb85c8e6)
    +++ b/typo3/sysext/redirects/Classes/Service/RedirectService.php    (date 1735123103958)
    @@ -417,7 +417,7 @@
                 $this->typoScriptCache,
             );
             $frontendTypoScript = $this->frontendTypoScriptFactory->createSetupConfigOrFullSetup(
    -            false,
    +            true,
                 $frontendTypoScript,
                 $site,
                 $pageInformation->getSysTemplateRows(),

    Bugfix for v12 (additionally fixes #99797)

    Index: typo3/sysext/redirects/Classes/Service/RedirectService.php
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/typo3/sysext/redirects/Classes/Service/RedirectService.php b/typo3/sysext/redirects/Classes/Service/RedirectService.php
    --- a/typo3/sysext/redirects/Classes/Service/RedirectService.php    (revision 1578898640ae3940645c475e4f8d4dfa821528ec)
    +++ b/typo3/sysext/redirects/Classes/Service/RedirectService.php    (date 1735149803147)
    @@ -23,6 +23,7 @@
     use Psr\Log\LoggerAwareInterface;
     use Psr\Log\LoggerAwareTrait;
     use TYPO3\CMS\Core\Context\Context;
    +use TYPO3\CMS\Core\Context\TypoScriptAspect;
     use TYPO3\CMS\Core\Domain\Repository\PageRepository;
     use TYPO3\CMS\Core\Exception\SiteNotFoundException;
     use TYPO3\CMS\Core\Http\Uri;
    @@ -403,11 +404,16 @@
                     ->withAttribute('site', $site)
                     ->withAttribute('siteLanguage', $site->getDefaultLanguage());
             }
    +
    +        // Set typoscript aspect with $forcedTemplateParsing (required for TypoScript setup initialization)
    +        GeneralUtility::makeInstance(Context::class)
    +            ->setAspect('typoscript', GeneralUtility::makeInstance(TypoScriptAspect::class, true));
    +
             $controller = GeneralUtility::makeInstance(
                 TypoScriptFrontendController::class,
                 GeneralUtility::makeInstance(Context::class),
                 $site,
    -            $site->getDefaultLanguage(),
    +            $originalRequest->getAttribute('language', $site->getDefaultLanguage()),
                 new PageArguments($site->getRootPageId(), '0', []),
                 $originalRequest->getAttribute('frontend.user')
             );
  16. Gerrit Code Review pushed patch set 1 for main to change 87805 status Accepted Under Review <span data-processor="relativetime" data-value="2025-01-18T14:09:01+00:00" > 01/18/25, 14:09 </span>

  17. Torben Hansen commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-01-24T09:05:10+00:00" > 01/24/25, 09:05 </span>

    Applied in changeset commit:3215625c8eaaece17154b0c81a7c2d95526f26d9.