Bug #103063
openExtbase repository does not respect fallback chain
0%
Description
Topic
In a site with multiple languages and fallback chains configured, extbase models retrieved by an extbase repository do not respect the configured fallback chains.
Example
SiteConfig (only relevant parts):
languages:
-
title: 'English (Global)'
enabled: true
languageId: 0
base: /en/
-
title: ES-ES
enabled: true
base: /es-es/
typo3Language: es
fallbackType: strict
flag: es
languageId: 15
-
title: 'AR-ES'
enabled: true
base: /es-ar/
typo3Language: es
fallbackType: fallback
fallbacks: 15
languageId: 5
Extbase Models in DB:
uid, sys_language_uid, title, l10n_parent 1, 0, 'Model 1 global', 0 2, 15, 'Model 1 spanish', 1 3, 0, 'Model 2 global', 0 4, 5, 'Model 2 spanish argentina', 3 5, 15, 'Model 2 spanish', 3
Using a extbase repository $repository->findAll() return the following results:
1, 0, 'Model 1 global', 0 4, 5, 'Model 2 spanish argentina', 3
instead of the expected result:
2, 15, 'Model 1 spanish', 1 4, 5, 'Model 2 spanish argentina', 3
I've tracked the problem down to
\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend->overlayLanguageAndWorkspaceForSingleRecord
in line 540 a new instance of LanguageAspect is created but without handing over the fallbackChain of the original languageAspect:
$customLanguageAspect = new LanguageAspect($languageUid, $languageUid, LanguageAspect::OVERLAYS_MIXED);
$row = $pageRepository->getLanguageOverlay($tableName, $row, $customLanguageAspect);
I am not sure, if this is done with purpose, but the pageRepository further more does not know about the configured fallbackChain and so cannot return the correct record. In my opinion the above code should look like this:
$customLanguageAspect = new LanguageAspect($languageUid, $languageUid, LanguageAspect::OVERLAYS_MIXED, $languageAspect->getFallbackChain());
$row = $pageRepository->getLanguageOverlay($tableName, $row, $customLanguageAspect);