#109683Undefined variable "tree" in Expression Language crashes DataHandler during CLI operations on orphaned records
Description
Hello,
When using the TYPO3 DataHandler within a CLI context (e.g., an UpgradeWizard), processing records that are orphaned or reside on non-existent pages leads to a fatal error in the Symfony Expression Language parser. This occurs because the tree object is only initialized if a rootline is successfully determined.
This issue is specifically present when using the global Configuration/page.tsconfig file, as the condition matching logic there does not gracefully handle the absence of the tree variable.
Reproducer
- Define a Page TSconfig condition in Configuration/page.tsconfig:
[916 in tree.rootLineIds] TCEMAIN.clearCacheCmd = 12 [END]
- Execute a DataHandler operation via CLI (e.g., an UpgradeWizard) on a record whose pid does not exist.
- The Symfony Expression Language parser fails because tree is completely missing from the context.
Current Behavior
The parser stops with the following error:
Variable "tree" is not valid around position 1 for expression "916 in tree.rootLineIds".
Because the variable is not registered at all when the rootline is empty, standard null-coalescing (tree ?? …) or optional chaining (tree?.) within the expression does not prevent the crash. This is due to the Symfony Expression Language being evaluated in a mode where unknown variables are not ignored:
if (!($this->flags & self::IGNORE_UNKNOWN_VARIABLES)) { ... }
The only current workaround is a complex and non-intuitive expression:
[916 in traverse((tree ?? {rootLineIds: []}), 'rootLineIds')]
Affected Component
The logic resides in IncludeTreeConditionMatcherVisitor.
The current implementation only adds tree to $enrichedVariables if $localRootLine is not empty:
$localRootLine = $variables['localRootLine'] ?? $fullRootLine;
if (!empty($localRootLine)) {
$tree = new \stdClass();
// ... initialization of $tree
$enrichedVariables['tree'] = $tree;
}
Expected Behavior
The tree variable should be initialized as an empty object or a null-safe entity by the IncludeTreeConditionMatcherVisitor even in CLI or orphaned record contexts. This would allow the use of the null-safe operator (tree?.rootLineIds) or simply return false for the condition without crashing the process.
Stefan
Reviews 2
Related issues 2
History 513
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2026-04-22T13:01:39+00:00" > 04/22/26, 13:01 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 93809 status
NewUnder Review <span data-processor="relativetime" data-value="2026-04-23T00:26:22+00:00" > 04/23/26, 00:26 </span> -
Gerrit Code Review pushed patch set 2 for main to change 93809 <span data-processor="relativetime" data-value="2026-04-23T00:48:04+00:00" > 04/23/26, 00:48 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 93809 <span data-processor="relativetime" data-value="2026-04-23T08:16:57+00:00" > 04/23/26, 08:16 </span>
-
Gerrit Code Review pushed patch set 1 for 14.3 to change 93822 <span data-processor="relativetime" data-value="2026-04-23T09:41:17+00:00" > 04/23/26, 09:41 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 93809 <span data-processor="relativetime" data-value="2026-04-23T09:56:36+00:00" > 04/23/26, 09:56 </span>
-
Gerrit Code Review pushed patch set 2 for 14.3 to change 93822 <span data-processor="relativetime" data-value="2026-04-23T09:57:04+00:00" > 04/23/26, 09:57 </span>
-
Gerrit Code Review pushed patch set 5 for main to change 93809 <span data-processor="relativetime" data-value="2026-04-23T10:17:56+00:00" > 04/23/26, 10:17 </span>
-
Gerrit Code Review pushed patch set 3 for 14.3 to change 93822 <span data-processor="relativetime" data-value="2026-04-23T10:18:13+00:00" > 04/23/26, 10:18 </span>
-
Christian Kuhn commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-04-23T12:15:08+00:00" > 04/23/26, 12:15 </span>Applied in changeset commit:68cea6ff506d4bb75cb958e679b5c0106b212e37.
-
Garvin Hicking changed Related to #106435 <span data-processor="relativetime" data-value="2026-04-24T04:48:05+00:00" > 04/24/26, 04:48 </span>
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-08-11T08:46:53+00:00" > 08/11/26, 08:46 </span> -
Benni Mack changed Related to #104608 <span data-processor="relativetime" data-value="2026-10-24T07:16:34+00:00" > 10/24/26, 07:16 </span>
Now the complex version is not working in Web Context. Changed it to:
[916 in (tree ?? {rootLineIds: []}).rootLineIds] TCAdefaults.pages.doktype = 15 TCAdefaults.pages.hidden = 0 [END]