Review main Merged

85832[TASK] Avoid calls to TemplatePaths constructor

Simon Praetorius CR +2 V +2 Normal +64 −36 updated 09/09/24, 11:24

Commit message

The constructor of Fluid's `TemplatePath` class allowed
both a package name and a configuration array (containing
`templateRootPaths`, `layoutRootPaths`, `partialRootPaths`
and a `format`). It also tried to set defaults for TYPO3,
without the base `TemplatePaths` class being part of TYPO3.

To streamline Fluid's API and to untangle Fluid's configuration
from TYPO3, both constructor variants have been soft-deprecated
with Fluid v2.15 and will log deprecation notices with Fluid v4.
In preparation of the switch to Fluid v4, all usages of the
constructor are removed from the core. A lot of this work
has already been done in previous patches.

The remaining usages are related to the `FluidEmail` class,
which unfortunately uses Fluid's `TemplatePaths` class as
API. In all cases, the default mailer configuration is extended,
which is part of the system configuration:

from DefaultConfiguration.php:

```
    'MAIL' => [ // Mail configurations to tune how \TYPO3\CMS\Core\Mail\ classes will send their mails.
        //…
        'format' => 'both',
        'layoutRootPaths' => [
            0 => 'EXT:core/Resources/Private/Layouts/',
            10 => 'EXT:backend/Resources/Private/Layouts/',
        ],
        'partialRootPaths' => [
            0 => 'EXT:core/Resources/Private/Partials/',
            10 => 'EXT:backend/Resources/Private/Partials/',
        ],
        'templateRootPaths' => [
            0 => 'EXT:core/Resources/Private/Templates/Email/',
            10 => 'EXT:backend/Resources/Private/Templates/Email/',
        ],
```

`format` is already problematic, because `both` is not a valid
value to Fluid. So that value is *not*  set in this patch because
`FluidEmail` overwrites the value internally anyways once `txt`,
`html` or `both` are rendered for an email.

The three path arrays are set by using the appropriate setter
methods of the `TemplatePaths` object and thus avoiding the
deprecated constructor. Merges with additional paths are
performed in the same way they were before.

Due to slightly different implementations, changes to tests
are necessary. The new implementation preserves numeric
array keys, while the old implementation didn't. However,
the order of the templates stays the same and overriding by
key is still possible.

Review

  • Code review CR +2 Done
    • Simon Praetorius +2
    • Markus Klein +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Simon Praetorius +2
    • Markus Klein +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 7

Review log 2030

Show 35 earlier messages
  1. Simon Praetorius uploaded patch set 1 08/30/24, 14:26

  2. core-ci voted on patch set 1 V -1 08/30/24, 14:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64536

  3. Simon Praetorius rebased onto patch set 2 V -1 08/30/24, 17:11

  4. core-ci voted on patch set 2 V -1 08/30/24, 17:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64542

  5. Simon Praetorius uploaded patch set 3 V -1 08/30/24, 17:40

  1. core-ci voted on patch set 3 V -1 08/30/24, 17:55 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64544

  2. Simon Praetorius updated the commit message in patch set 4 V -1 08/30/24, 21:25

  3. core-ci voted on patch set 4 V -1 08/30/24, 21:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64560

  4. Simon Praetorius uploaded patch set 5 V -1 09/03/24, 17:56

  5. core-ci voted on patch set 5 V -1 09/03/24, 18:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64692

  6. core-ci commented on patch set 5 09/03/24, 18:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64692

  7. core-ci voted on patch set 5 V +1 09/03/24, 18:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64692

  8. Simon Praetorius uploaded patch set 6 V +1 09/04/24, 18:41

  9. Simon Praetorius updated the commit message in patch set 7 09/04/24, 18:43

  10. Simon Praetorius marked it ready for review 09/04/24, 18:45

  11. core-ci voted on patch set 6 V +1 09/04/24, 18:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64804

  12. core-ci voted on patch set 7 V +1 09/04/24, 18:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64805

  13. Markus Klein commented on patch set 7 09/04/24, 20:37

    RecoveryConfiguration.php:69

    shouldn't we keep the array_replace_recursive() here?

    StageChangeNotification.php:145

    same here
  14. Stefan Bürk commented on patch set 7 09/04/24, 20:47

    AuthenticationService.php:46

    I'm not sure if we should use `array_replace()` here to emphasize what here really happens as understanding this construct may be not obvious on the first look: * array key and value unpacking flattern * replaceing key `20` with manual item below Albeit, I love that construct/syntax using more "known" construct may be usefull for not so experienced people ?

    SystemStatusUpdateTask.php:121

    I'm not sure if we should use `array_replace()` here to emphasize what here really happens as understanding this construct may be not obvious on the first look: * array key and value unpacking flattern * replaceing key `20` with manual item below Albeit, I love that construct/syntax using more "known" construct may be usefull for not so experienced people ?
  15. Stefan Bürk commented on patch set 7 09/04/24, 20:49

    RecoveryConfiguration.php:69 Reply

    recursive does not make sense. The recursive was because it was applied on an array containing subarrays with `templateRootPaths`. The structure here is ``` int => string ``` and recursive does not make any sense.

    StageChangeNotification.php:145 Reply

    recursive does not make sense. The recursive was because it was applied on an array containing subarrays with `templateRootPaths`. The structure here is ``` int => string ``` and recursive does not make any sense.
  16. Simon Praetorius commented on patch set 7 09/05/24, 07:03

    AuthenticationService.php:46 Reply

    I think I'll switch these to `array_replace()` in all places. That way the API is used in the same way everywhere.
  17. Markus Klein commented on patch set 7 09/05/24, 07:17

    RecoveryConfiguration.php:69 Reply

    Right, I overlooked that.

    StageChangeNotification.php:145 Reply

    Acknowledged
  18. Simon Praetorius uploaded patch set 8 V +1 09/05/24, 08:22

  19. Simon Praetorius commented on patch set 8 09/05/24, 08:23

    AuthenticationService.php:46 Reply

    Done

    SystemStatusUpdateTask.php:121 Reply

    Done
  20. core-ci voted on patch set 8 V +1 09/05/24, 08:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64845

  21. Markus Klein voted on patch set 8 CR +1 09/08/24, 07:45

  22. Markus Klein voted on patch set 8 V +1 09/09/24, 08:02

  23. Stefan Bürk voted on patch set 8 CR +1 V +1 09/09/24, 11:03

  24. Simon Praetorius voted on patch set 8 CR +2 V +2 09/09/24, 11:24

  25. Simon Praetorius merged patch set 9 09/09/24, 11:24