Skip to content
Snippets Groups Projects
Commit c768d0fd authored by Simon Praetorius's avatar Simon Praetorius
Browse files

[TASK] Avoid calls to TemplatePaths constructor

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.

Resolves: #104823
Releases: main
Change-Id: Iee9e08e3320657bfffa4c069da94efcf0f9ebd2a
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85832


Reviewed-by: default avatarSimon Praetorius <simon@praetorius.me>
Tested-by: default avatarcore-ci <typo3@b13.com>
Reviewed-by: default avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarSimon Praetorius <simon@praetorius.me>
Tested-by: default avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
parent 0ec6efff
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment