Project

General

Profile

Actions

Bug #102742

closed

TypoScript constants not usable in value modification addToList()

Added by Karsten Nowak (undkonsorten) 11 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2024-01-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If we use constants in value modifications like addToList() (maybe others too) they are not replaced with the value of the constants. Used constants are not nested constants!

Example:

# TypoScript Constants
test.foo = bar
# TypoScript Setup
page.1 = TEXT
page.1 {
  value = Test1
  value := addToList({$test.foo})
}
page.2 = TEXT
page.2 {
  value = Test2
  value := addToList(one,two)
  wrap = <br />|
}

Expected output should be

Test1,bar
Test2,one,two

but is

Test1,{$test.foo}
Test2,one,two

In "Active TypoScript" with activated checkbox "Substitute constants in setup" it is also not replaced.

Environment: TYPO3 12.4.9 and PHP 8.2.4


Files


Related issues 4 (0 open4 closed)

Related to TYPO3 Core - Feature #97816: New TypoScript parserClosed2022-06-27

Actions
Related to TYPO3 Core - Task #103944: Update less class state in TypoScript tokenizersClosed2024-05-28

Actions
Related to TYPO3 Core - Feature #103671: Provide null coalesce operator for TypoScript constantsClosedBenjamin Franzke2024-04-19

Actions
Related to TYPO3 Core - Task #103982: Require array in setFlatConstants()Closed2024-06-05

Actions
Actions #1

Updated by Christian Kuhn 11 months ago

Actions #2

Updated by Christian Kuhn 10 months ago ยท Edited

Confirmed. This is not parsed. Not even tokenized. I guess we completely missed this since it was never documented function body values could be constants.

This seems to be a rather seldom used feature though, otherwise we'd have seen more people complaining about this already.

Here is what has to happen:

LossyTokenizer and LosslessTokenizer need to parse the 'token body' to create a T_VALUE & T_CONSTANT stream instead of just a singe T_VALUE. The key change is to mess around with $this->currentLineString and trigger parseValueForConstants() for the body. This needs to be done carefully, especially in LossLessTokenizer. IdentifierFunctionLine has to be changed to carry this stream instead of a single value. The tokenizer needs to create either a ConstantAwareTokenStream when there is a constant in there, or a TokenStream (this is pretty clever since creating special objects during tokenizing already if a constant is involved prevents ast builder (which is done more often than tokenizing due to cache layers) from scannig for constants often). Additional unit tests should verify this works. The code involved isn't trivial, but a change should be do-able, the LossyTokenizer will be more easy to handle than the LosslessTokenizer. There is existing code in the two tokenizers that do similar things already.

And I think that's basically it, constant substitution then should probably auto kick in within AST-builder I guess, but it's possible it needs a minor change to be aware of streams instead of a single token only. An AST builder test will find out details. We may need to stringify such ConstantAwareTokenStream relatively early within the AST builder to resolve T_CONSTANT to the final value, otherwise a chain like addToList(${my.constant}) (which is resolved to say "42") and then another call with removeFromList(42) wouldn't work. Tests should verify this is fine.

Actions #3

Updated by Garvin Hicking 10 months ago

(Will work on this, if someone else wants in too, let me know on Slack or here)

Actions #4

Updated by Gerrit Code Review 10 months ago

  • Status changed from New to Under Review

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #5

Updated by Gerrit Code Review 9 months ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #6

Updated by Gerrit Code Review 9 months ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #7

Updated by Gerrit Code Review 9 months ago

Patch set 11 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #8

Updated by Gerrit Code Review 9 months ago

Patch set 12 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #9

Updated by Gerrit Code Review 9 months ago

Patch set 13 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #10

Updated by Gerrit Code Review 9 months ago

Patch set 14 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #11

Updated by Gerrit Code Review 9 months ago

Patch set 15 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #12

Updated by Gerrit Code Review 9 months ago

Patch set 16 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #13

Updated by Gerrit Code Review 9 months ago

Patch set 17 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #14

Updated by Gerrit Code Review 7 months ago

Patch set 18 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #15

Updated by Gerrit Code Review 6 months ago

Patch set 19 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #16

Updated by Gerrit Code Review 6 months ago

Patch set 20 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #17

Updated by Christian Kuhn 6 months ago

  • Related to Task #103944: Update less class state in TypoScript tokenizers added
Actions #18

Updated by Gerrit Code Review 6 months ago

Patch set 21 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #19

Updated by Gerrit Code Review 6 months ago

Patch set 22 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #20

Updated by Gerrit Code Review 6 months ago

Patch set 23 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #21

Updated by Gerrit Code Review 6 months ago

Patch set 24 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #22

Updated by Gerrit Code Review 6 months ago

Patch set 25 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #23

Updated by Gerrit Code Review 6 months ago

Patch set 26 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #24

Updated by Gerrit Code Review 6 months ago

Patch set 27 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #25

Updated by Gerrit Code Review 6 months ago

Patch set 28 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #26

Updated by Gerrit Code Review 6 months ago

Patch set 29 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #27

Updated by Gerrit Code Review 6 months ago

Patch set 30 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #28

Updated by Gerrit Code Review 6 months ago

Patch set 31 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #29

Updated by Gerrit Code Review 6 months ago

Patch set 32 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #30

Updated by Gerrit Code Review 6 months ago

Patch set 33 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #31

Updated by Gerrit Code Review 6 months ago

Patch set 34 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #32

Updated by Christian Kuhn 6 months ago

a constant:

project = TYPO3v12

a usage:

page.40 = TEXT
page.40.value = foo
page.40.value := addToList({$project})

BE display: see screenshot

Actions #33

Updated by Christian Kuhn 6 months ago

  • Related to Feature #103671: Provide null coalesce operator for TypoScript constants added
Actions #34

Updated by Gerrit Code Review 6 months ago

Patch set 35 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82633

Actions #35

Updated by Gerrit Code Review 6 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84498

Actions #36

Updated by Christian Kuhn 6 months ago

This took a while, but it's now done and will be available with next v12 patch level.

Actions #37

Updated by Garvin Hicking 6 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #38

Updated by Christian Kuhn 6 months ago

  • Related to Task #103982: Require array in setFlatConstants() added
Actions #39

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF