Review main Merged

83912[FEATURE] Provide null coalescing operator for TypoScript constants

Benjamin Franzke CR +2 V +2 Normal +240 −5 updated 04/22/24, 07:04

Commit message

TypoScript constants expressions have been extended to support a null
coalescing operator (`??`) as a way for providing a migration path from
a legacy constant name to a newer name, while providing full backwards
compatibility for the legacy constant name, if still defined.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • Torben Hansen +1
    • Stefan Bürk +1
    • Christian Kuhn +1
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • Torben Hansen +1
    • Stefan Bürk +1
    • Christian Kuhn +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 4

Review log 2433

Show 68 earlier messages
  1. Benjamin Franzke uploaded patch set 1 04/18/24, 08:15

  2. Benjamin Franzke commented on patch set 1 04/18/24, 08:16

    ConstantAwareTokenStream.php:53

    Original comment on this by @lolli@schwarzbu.ch in https://review.typo3.org/c/Packages/TYPO3.CMS/+/83321/6#message-53ee0aa2fbe2d0590347642317c8c18b4404b907 > It's an interesting idea to allow a syntax like ${constantName1 ?? constantName2}. > > I think we need to somehow have this added to the Tokeninzer, though: maybe some 'constantNullable' token that represents the ??, then see here if peekNext() of the tokenStream is such a token, then act accordingly. That's one option. We could also keep it that way, but it smells unclean - for instance we can't analyze this in other modules (i'd like to show you an example / thoughts on this, Benjamin). Not entirely sure how to approach it to end up with a properly modeled token stream. > > If we agree we need such a thing, we should have a talk on which options we have, Benjamin.
  3. core-ci voted on patch set 1 V +1 04/18/24, 08:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56232

  4. Benjamin Franzke commented on patch set 1 04/18/24, 10:19

    ConstantAwareTokenStream.php:53 Reply

    Hey lolli, I've now extracted this code from https://review.typo3.org/c/Packages/TYPO3.CMS/+/83321 as we also need it in upcoming sets where settings shall be renamed (desire by Benni and Benji): > https://review.typo3.org/c/Packages/TYPO3.CMS/+/83526/53/typo3/sysext/felogin/Configuration/TypoScript/setup.typoscript Maybe we can have a quick chat an discuss when/how we get this implemented into the tokenizer. I support/like the idea, but don't know how to do that right now, as that means that the tokenizer needs to parse `${…}` contents – which doesn't happen right now IIRC.
  5. Benjamin Franzke commented on patch set 1 04/19/24, 06:48

    ConstantAwareTokenStream.php:53 Reply

    Also we need to decide what the syntax should look like: ``` {$foo ?? bar} ``` or ``` {$foo ?? $bar} ``` I chosed the first one, basically because of the current parser that treats `{$` as the start-identifier for a constant-expression: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/TypoScript/Tokenizer/LosslessTokenizer.php#L882-L908 therefore it felt logical to *not* repeat `$` inside the expression. On the other hand the second syntax would probably be more intuitive for end-users and the expected syntax (e.g. @benjamin.kott@outlook.com would have expected that notation). This syntax will be more challenging for the Tokenizer to differentiate a constant expression from TypoScript block (needs to check whether the closing `}` is on the same line).
  6. Benjamin Franzke uploaded patch set 2 V +1 04/19/24, 07:28

  7. Benjamin Franzke commented on patch set 2 04/19/24, 07:30

    ConstantAwareTokenStream.php:53 Reply

    I've now switched to `{$foo ?? $bar}`
  8. core-ci voted on patch set 2 V +1 04/19/24, 07:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56300

  1. Benjamin Franzke uploaded patch set 3 V +1 04/19/24, 12:43

  2. core-ci voted on patch set 3 V +1 04/19/24, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56336

  3. Christian Kuhn uploaded patch set 4 V +1 04/19/24, 19:35

  4. Christian Kuhn commented on patch set 3 04/19/24, 19:35

    ConstantAwareTokenStream.php:76

    array ;)
  5. core-ci voted on patch set 4 V +1 04/19/24, 19:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56354

  6. Christian Kuhn uploaded patch set 5 V +1 04/19/24, 19:42

  7. Christian Kuhn updated the commit message in patch set 6 04/19/24, 19:43

  8. Christian Kuhn uploaded patch set 7 04/19/24, 19:45

  9. Christian Kuhn voted on patch set 7 CR +1 V +1 04/19/24, 19:45

  10. core-ci voted on patch set 5 V +1 04/19/24, 19:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56356

  11. core-ci voted on patch set 7 V +1 04/19/24, 19:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56358

  12. core-ci voted on patch set 6 V +1 04/19/24, 19:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56357

  13. Christian Kuhn uploaded patch set 8 CR +1 V +1 04/19/24, 19:59

  14. Christian Kuhn voted on patch set 8 CR +1 V +1 04/19/24, 20:00

  15. core-ci voted on patch set 8 V +1 04/19/24, 20:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56359

  16. Garvin Hicking commented on patch set 8 CR +1 V +1 04/19/24, 21:23

    nifty :-)

    Feature-103671-ProvideNullCoalescingOperatorForTypoScriptConstants.rst:34

    "breaking"
  17. Benni Mack commented on patch set 9 CR +1 V +1 04/19/24, 22:33

    Published edit on patch set 8.
  18. Benni Mack commented on patch set 9 CR +1 V +1 04/19/24, 22:33

    Feature-103671-ProvideNullCoalescingOperatorForTypoScriptConstants.rst:34 Reply

    Done
  19. core-ci voted on patch set 9 V +1 04/19/24, 22:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/56361

  20. Garvin Hicking voted on patch set 9 CR +1 V +1 04/20/24, 07:06

  21. Christian Kuhn voted on patch set 9 CR +1 V +1 04/20/24, 08:24

  22. Stefan Bürk voted on patch set 9 CR +1 V +1 04/20/24, 09:15

  23. Torben Hansen voted on patch set 9 CR +1 V +1 04/20/24, 10:55

  24. Benjamin Franzke voted on patch set 9 CR +2 V +2 04/22/24, 07:04

  25. Benjamin Franzke merged patch set 10 04/22/24, 07:04