Skip to content
Snippets Groups Projects
Commit 837f5b0b authored by Garvin Hicking's avatar Garvin Hicking Committed by Christian Kuhn
Browse files

[BUGFIX] Add constant evaluation in TypoScript functions

We missed a TypoScript feature with the new parser.
Function operator modifier values can use constants:

foo = 42
foo := addToList({$my.constant})

The solution is two fold: Until now, the value of a
function body was a single T_VALUE token. This is
turned into a stream of tokens that can consist of
multiple T_VALUE and T_CONSTANT tokens. This is
handled in the tokenizers. Secondly, the AST builders
need to deal with these token streams now, and take
care available constants are hand over to
ConstantAwareTokenStream before the stream is cast
to string and single functions are evaluated.

The BE modules *do* reflect constant substitutions in
function modifier bodies, but not in an ideal way.
An @todo within the responsible CommentAwareAstBuilder
outlines ideas how this could be improved.

Note TYPO3 v13 supports constant fallbacks here
as well, this syntax feature came with #103671.
This works, but is NOT supported in v12:

foo := addToList({$my.constant ?? $fallback.constant})

Resolves: #102742
Related: #97816
Related: #103671
Releases: main, 12.4
Change-Id: Ib5e0872fe1ea2b78bd0a7e05caccd9874b5668d4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84498


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 9e7025c7
Branches
Tags
No related merge requests found
Showing
with 325 additions and 78 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment