Issue Bug Closed

#106435Conditions using `tree` may fail in TSconfig

Albrecht Köhnlein 03/26/25, 09:48 updated 04/24/26, 04:49

Description

Hi everybody,

I am using `tree` in conditions inside TSconfig as the documentation mentions it: https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/UsingSettingTSconfig/Conditions.html#tree-rootlineids

It works in most cases, but I realized that it fails and writes an error log entry, when I create a translation of a sys_file_metadata record. In this case, the expression variable `tree` is not set.

This example condition:

[4 in tree.rootLineIds]

leads to this esample error:

Variable "tree" is not valid around position 6 for expression `4 in tree.rootLineIds`.

It’s even the same error if I try to introduce a simple null-coalescing operator.

Variable "tree" is not valid around position 7 for expression `4 in (tree?.rootLineIds ?? [])`.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 15

  1. Daniel Siepmann commented <span data-processor="relativetime" data-value="2025-04-01T06:39:36+00:00" > 04/01/25, 06:39 </span>

    I had more and more issues during upgrades to v13.

    And I stumbled upon this option of the symfony component while debugging: self::IGNORE_UNKNOWN_VARIABLES
    . Did anyone decide to not use this flag? Would it make sense to use this flag?
    Did anyone give this flag a try?

    E.g. sometimes you access a page in tsconfig, or request in TypoScript which might be loaded in CLI or backend context where those are not always available.
    It might help to reduce broken conditions and forcing people to rework conditions?

  2. Albrecht Köhnlein commented <span data-processor="relativetime" data-value="2025-04-07T06:19:35+00:00" > 04/07/25, 06:19 </span>

    I would prefer that errors are not generally disabled. If someone really uses invalid code (e.g. a typo), I think errors should be logged.

    In my opinion the best solution would be to have all variables always available – maybe with empty values.

  3. Daniel Siepmann commented <span data-processor="relativetime" data-value="2025-04-07T19:36:39+00:00" > 04/07/25, 19:36 </span>

    Yeah I had this due to some other third party building the TypoScript itself without providing the variables, so please ignore my last comment.

  4. André Buchmann commented <span data-processor="relativetime" data-value="2025-04-11T19:44:47+00:00" > 04/11/25, 19:44 </span>

    I’Ve got the same error in TPYO3 13.4.9 with this condition:

    [tree.pagelayout === "pagets__newsPost" || 3 in tree.rootLineIds]

    @whnsnn blogged about a possible solution which looks very strange, but hey, it works: https://www.koehnlein.dev/en/blog/2025/tsconfig-condition-nullsafe/

    [((tree ?? null)?.pagelayout ?? '') === "pagets__newsPost" || 3 in ((tree ?? null)?.rootLineIds ?? [])]
  5. Philipp Gollmer commented <span data-processor="relativetime" data-value="2025-04-14T09:54:04+00:00" > 04/14/25, 09:54 </span>

    I can confirm that even in version 13.4.9 the log is full of GigaByte wise error logs due to the Typoscript conditions.

    [ERROR] component="TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor": TypoScript condition [tree.level == 1] could not be parsed: Variable "tree" is not valid around position 1 for expression `tree.level == 1`.- SyntaxError: Variable "tree" is not valid around position 1 for expression `tree.level == 1`., in file /var/www/html/vendor/symfony/expression-language/Parser.php:257 - {"expression":"tree.level == 1","error":"Variable \"tree\" is not valid around position 1 for expression `tree.level == 1`.","exception":"Symfony\\Component\\ExpressionLanguage\\SyntaxError: Variable \"tree\" is not valid around position 1 for expression `tree.level == 1`. in /var/www/html/vendor/symfony/expression-language/Parser.php:257
    [ERROR] component="TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor": TypoScript condition [traverse(page, 'uid') == 5] could not be parsed: Variable "page" is not valid around position 10 for expression `traverse(page, 'uid') == 5`. Did you mean "date"?- SyntaxError: Variable "page" is not valid around position 10 for expression `traverse(page, 'uid') == 5`. Did you mean "date"?, in file /var/www/html/vendor/symfony/expression-language/Parser.php:257 - {"expression":"traverse(page, 'uid') == 5","error":"Variable \"page\" is not valid around position 10 for expression `traverse(page, 'uid') == 5`. Did you mean \"date\"?","exception":"Symfony\\Component\\ExpressionLanguage\\SyntaxError: Variable \"page\" is not valid around position 10 for expression `traverse(page, 'uid') == 5`. Did you mean \"date\"? in /var/www/html/vendor/symfony/expression-language/Parser.php:257
    [ERROR] component="TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor": TypoScript condition [tree.pagelayout == "pagets__Persons"] could not be parsed: Variable "tree" is not valid around position 1 for expression `tree.pagelayout == "pagets__Persons"`.- SyntaxError: Variable "tree" is not valid around position 1 for expression `tree.pagelayout == "pagets__Persons"`., in file /var/www/html/vendor/symfony/expression-language/Parser.php:257 - {"expression":"tree.pagelayout == \"pagets__Persons\"","error":"Variable \"tree\" is not valid around position 1 for expression `tree.pagelayout == \"pagets__Persons\"`.","exception":"Symfony\\Component\\ExpressionLanguage\\SyntaxError: Variable \"tree\" is not valid around position 1 for expression `tree.pagelayout == \"pagets__Persons\"`. in /var/www/html/vendor/symfony/expression-language/Parser.php:257
  6. Česlav Przywara commented <span data-processor="relativetime" data-value="2025-05-02T10:28:14+00:00" > 05/02/25, 10:28 </span>

    I get this error in logs (on TYPO3 13.4.9) when saving file metadata via Filelist module. The metadata are saved without issues.

  7. Ingo Hollmann commented <span data-processor="relativetime" data-value="2025-05-22T08:29:45+00:00" > 05/22/25, 08:29 </span>

    Same here, conditions in TypoScript throws error:

    TypoScript condition [16 in tree.rootLineIds] could not be parsed: Variable "tree" is not valid around position 7 for expression `16 in tree.rootLineIds`
    TypoScript condition [traverse(page, "doktype") == 112] could not be parsed: Variable "page" is not valid around position 10 for expression `traverse(page, "doktype") == 112`. Did you mean "date"?
  8. Florian Schuhmann commented and changed TYPO3 Version 13 12 <span data-processor="relativetime" data-value="2025-06-03T11:27:32+00:00" > 06/03/25, 11:27 </span>

    I can confirm this error also for v12.4.31 when browsing in the Filelist.
    The affected condition is loaded by ExtensionManagementUtility::addPageTSConfig within an ext_localconf.php

    {
    "message":"Expression could not be parsed.",
    "component":"TYPO3.CMS.Core.TypoScript.IncludeTree.Visitor.IncludeTreeConditionMatcherVisitor",
    "context":{"expression":"1660 in tree.rootLineIds"},
    "url":"https:\/\/********.local\/typo3\/module\/file\/list?token=--AnonymizedToken--&id=2%3Asample%2F&"
    }

    As Workaround i can confirm that the following syntax works:

    [1660 in ((tree ?? null)?.rootLineIds ?? []]

  9. Garvin Hicking commented and changed status New Closed <span data-processor="relativetime" data-value="2026-04-24T04:49:25+00:00" > 04/24/26, 04:49 </span>

    Thanks for raising this dupe, I’ll close it due to the fix. We have decided ahainst a v13 backport for now because v13 is now in “priority bugfixes” mode, but you could try to apply the composer patch there.