Review 12.4 Merged

84498[BUGFIX] Add constant evaluation in TypoScript functions

Christian Kuhn CR +2 V +2 Hard +325 −78 updated 06/05/24, 10:07

Commit message

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})

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 3

Files 11