Project

General

Profile

Actions

Bug #81099

closed

Extension cannot override default (fallback) templateRootPaths/partialRootPaths/partialRootPaths

Added by Anonymous almost 7 years ago. Updated 8 months ago.

Status:
Resolved
Priority:
Must have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2017-05-01
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

I upgraded from 7.6 to 8.7 today and discovered a regression in TemplatePaths.php.

Wanted behaviour (TYPO3 7.6):

I have two extensions:
1. Extension "base_templates" contains a lot of fluid Partials
2. Extension "specific_templates" uses the Partials from "base_templates" and overwrites some of them.

So fluid should use the following order:
1. Check if "specific_templates" has the searched partial
2. Check if "base_templates" has the search partial

So "base_templates" is a fallback for "specific_templates".

To achieve this behaviour I configured partialRootPaths of "specific_templates":

plugin.tx_specific_templates {
    view {
        partialRootPaths {
            10 = EXT:base_templates/Resources/Private/Partials/
            20 = EXT:specific_templates/Resources/Private/Partials/
        }
    }
}

This setup worked in TYPO3 7.6 (Higher key overwrites lower key).

Actual behaviour (TYPO3 8.7):

8.7 changed the merging of default partialRootPaths and configured partialRootPaths.
The problem is "getContextSpecificViewConfiguration" in TemplatePaths.php:
https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-7-1/typo3/sysext/fluid/Classes/View/TemplatePaths.php#L77

Since the partialRootPaths.0 is always set to EXT:specific_templates/Resources/Private/Partials/ they always get overwritten by Partials in EXT:base_templates/Resources/Private/Partials/.
The array_merge in https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-7-1/typo3/sysext/fluid/Classes/View/TemplatePaths.php#L124 makes it impossible to overwrite partialRootPaths.0, because numeric array keys are not overwritten but appended.

So the result is always the following:

array (
  0 => 'BASE_PATH/www/typo3conf/ext/specific_templates/Resources/Private/Partials/',
  1 => 'BASE_PATH/www/typo3conf/ext/base_templates/Resources/Private/Partials/',
)

Wanted result:

array (
  0 => 'BASE_PATH/www/typo3conf/ext/base_templates/Resources/Private/Partials/',
  1 => 'BASE_PATH/www/typo3conf/ext/specific_templates/Resources/Private/Partials/',  
)

Possible solutions

Replace

$paths[$name] = array_merge($defaultPaths, (array)$configuredPaths[$name]);
with (used in 8.5.1 https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_8-5-1/typo3/sysext/fluid/Classes/View/TemplatePaths.php#L120)
$paths[$name] = (array)$configuredPaths[$name] + $defaultPaths;

Sadly this seems to cause other problems: #79681,#79290

Maybe we should just check if partialRootPaths.0 is explicitly set with TypoScript and in this case do not set the default partialRootPaths?


Files

bhdummy.zip (7.2 KB) bhdummy.zip Riccardo De Contardi, 2017-08-02 13:03
cattura.png (17.3 KB) cattura.png Riccardo De Contardi, 2017-08-02 13:04

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #79681: Configured Fluid template not foundClosedNicole Cordes2017-02-08

Actions
Related to TYPO3 Core - Bug #79290: Fluid cannot override default resolved paths if default paths existClosed2017-01-12

Actions
Has duplicate TYPO3 Core - Bug #79926: InvalidTemplateResourceException never thrownClosed2017-02-20

Actions
Actions

Also available in: Atom PDF