Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Ready for review Orphaned

84314[FEATURE] Symfony expressions for TypoScript if function

Remo H. CR -1 V -1 Normal +63 −1 updated 04/21/26, 14:59

Commit message

Adds a new property expression to the if function.
The property is of type string/stdWrap and expects
a valid Symfony expression/condition.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 8
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/14/84314/8 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/14/84314/8 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -1 Needs a vote
    • Stefan Bürk -1
    • Simon Schaufelberger +1
  • Verified V -1 Blocked
    • Stefan Bürk -1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1826

Show 1 earlier messages
  1. Remo H. uploaded patch set 1 05/19/24, 18:29

  1. core-ci voted on patch set 1 V -1 05/19/24, 18:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57919

  2. Remo H. uploaded patch set 2 V -1 05/20/24, 07:36

  3. core-ci voted on patch set 2 V +1 05/20/24, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57940

  4. Chris Müller updated the commit message in patch set 3 V +1 05/20/24, 15:42

  5. Chris Müller commented on patch set 3 05/20/24, 15:43

    Feature-103860-SymfonyExpressionForTyposcriptIfFunction.rst :15

    typoe -> type
  6. core-ci voted on patch set 3 V +1 05/20/24, 15:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57945

  7. Remo H. uploaded patch set 4 V +1 05/20/24, 18:48

  8. core-ci voted on patch set 4 V +1 05/20/24, 18:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57946

  9. Chris Müller commented on patch set 4 05/21/24, 15:46

    Feature-103860-SymfonyExpressionForTyposcriptIfFunction.rst :15 Reply

    Done
  10. Simon Schaufelberger updated the commit message in patch set 5 V +1 05/22/24, 00:09

  11. core-ci voted on patch set 5 V +1 05/22/24, 00:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58009

  12. Simon Schaufelberger commented on patch set 5 05/22/24, 08:14

    please use your real name in your TYPO3 profile. https://docs.typo3.org/m/typo3/guide-contributionworkflow/main/en-us/Setup/Git/Index.html#set-username-and-email and change it also on my.typo3.com
  13. Remo H. updated the commit message in patch set 6 V +1 05/22/24, 18:33

  14. core-ci voted on patch set 6 V +1 05/22/24, 18:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58067

  15. Simon Schaufelberger updated the commit message in patch set 7 V +1 05/22/24, 23:03

  16. Simon Schaufelberger commented on patch set 7 CR +1 05/22/24, 23:03

    Reply

    Done
  17. core-ci voted on patch set 7 V +1 05/22/24, 23:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58073

  18. Simon Schaufelberger uploaded patch set 8 CR +1 V +1 05/22/24, 23:23

  19. core-ci voted on patch set 8 V +1 05/22/24, 23:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58074

  20. Simon Schaufelberger voted on patch set 8 CR +1 05/22/24, 23:39

  21. Stefan Bürk commented on patch set 8 CR -2 05/23/24, 05:02

    Unresolved

    temp -2
  22. Stefan Bürk commented on patch set 8 CR -1 V -1 05/29/24, 08:14

    Thanks @r3h6@outlook.com for this patch. Looking deeper on it, I have some painpoints with the current implementation. From a integrator point of view, I would expect that everything which is possible in normal TypoScript conditions [1] is possible and work the same for the `if { expression = ... }`. But that is not the case, even if the expression is defined in TypoScript, this expression is evaluated by the ContentObjectRenderer at a later point NOT having all the context data set like the resolver used during the TypoScript condition handling. For example, following would not work, because the request site object is not available in the resolver created in the ContentObjectRenderer: ``` page.10 = TEXT page.10 { value = Hello world! if { expression = site("rootPageId") == 1 expression.insertData = 1 } } ``` If we take the current implementation it's more than likly that we get a raising flood of issues on forge and slack channels why basic TypoScript conditions does not work in that case. TBH - I did not debuged it if this is a parsing issue, or simply the fact that the variable are not assigned to the resolver instance - like it is done for doing the resolving for the usual TypoScript conditions in the TypoScript AST chain. However, to make this in anyway takable I would say that: * it **must** be ensured to act exactly the same as usual TypoScript conditions * same values needs to be assigned (which is quite a undertaking and not easily doable) and ensured to be aligned to what is possible for normal conditions * possible functionality / condition needs to be coverd by functional tests * the resolver context needs to get another identifier - it is not TypoScript (see other comment) Even if we document the "different" behaviour in the changelog entry and later in the documentation (which will be quite a task for the documentation team) people will not regonize and understand **why** this acts differently - because it is TypoScript. If they read that at all. I would prefere to avoid this feature with this difference and potential for a highly raise in support questions and tickets stealing time from people. Thus I trade my temporary -2 with a -1 for now - but will add it again if the questions above are not tackled. Note: Even if this is taken a "good to take" implementation, than it **must** documented properly the difference and make it really clear - so we could at least say "yeah, it's broken but we documented it that way, see here XY". Note: I did not checked yet how this counteracts with the other if {} typoscript posibilities. This needs deep testing and good test coverage, I'd say.

    ContentObjectRenderer.php:2497 Unresolved

    'typoscript' is literally not the correct context here - albeit defined in TypoScript, the resolving is done at a later point. And it does not contain all the variables like the real 'typoscript' context, because they are not assigned to due the `[]` below.

    ContentObjectRendererTest.php:4818 Unresolved

    Using callbacks to execut init stuff from static not test instance context is weired. This should be extracted to dedicated tests doing the mock creation in the test method directly. Further, mocking the expression here is kind of weired as the test nearly use-less, as it does not really test if expressions really work (real live). This needs to be moved to functional tests and with more realistic tests (usual TypoScript thinkable conditions, for exampe with `site("rootPageId")`).
  23. Benni Mack commented on patch set 8 04/24/25, 14:52

    Reply

    Hey, coming back to this... how about we don't extend checkIf ("if") but actually introduce a new option called "when": page.10 = TEXT page.10.value = Benni page.10.override = Stefan page.10.override.when = request.queryParams()["admin"] == 1
  24. Stefan Bürk commented on patch set 8 04/26/25, 22:35

    Reply Unresolved

    Again, we should take into account what an integrator is expecting when writing this TypoScript in comparison to when it is evaluated. TypoScript conditions (Symfony Expressions): ``` [request.queryParams() .... ] ``` are evaluated when parsing and processing the TypoScript and has all that stuff available and set, like the request,site object, page object etc. The `stdWrap.if` is a ContentObject thing and is evaluated when the content object is rendered/processed .. outside of the TypoScript context. The suggested override.when would also be a stdWrap / ContentElement thing and has the same issue like adding it to the if as alternative, except that it is made clearer. but how would it be act when `when` and `if` is provided ? The current implementation adding symfony expression as ability to the `stdWrap.if` instanciates expression with the `TypoScript` context (name), but fails to register all the variables like the request, site objec,t apge object etc and would not be available therefore. So, we need either provide a new context `ContextObject` to have a difference here and additional ensure to register ALL variables/context information which is availavel when evaluated (interpreted) during TypoScript script. Otherwise we really need to document that a TypoScript notation may differ base don the context and that not everything is possible as "override.when" / "if.expression" like it is for TypoScript conditiotions directly. I refere with the aforemention things to this: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84314/8/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#2497 Simply using `TypoScript` as context does not provide the same variables as it is available for TypoScript conditions directly. They need to be passed as array in L2498 instead of the empty array. For TypoScrpt this is handled here: https://github.com/TYPO3/typo3/blob/b133516b9d36895eb7ad393dad6ff21dc8a1e507/typo3/sysext/core/Classes/TypoScript/IncludeTree/Visitor/IncludeTreeConditionMatcherVisitor.php#L146 The method builds a lot of assignments which are missing / not set. And again, that expression is later evaluated within ContentObject rendering, not as part of the TypoScript parsing and processing earlier. If we allow that we need to ensure that for the expression (if/when) the same variables are available like in TypoScript otherwise we will give Integrators a hard time not `regonizing` that this is another context albeit written as TypoScript and acting other / having other context variables set. They would always referes to TypoScript (Condition) documentation. Don't get me wrong. I have not general something against this. But either this needs to be aligned and working exactly the way a Integrator will expect it, requiring to register all the same things or document the difference which most of the integrator will never read and fail to get the reasong why it differs. Beside that, if content objects are rendert in some way directly it may not so easy to ensure these "variables".
  25. Benni Mack wrote 04/21/26, 14:59

    Removed cc Benni Mack.