Project

General

Profile

Actions

Bug #103063

open

Extbase repository does not respect fallback chain

Added by Jens Bergau 10 months ago. Updated 5 days ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2024-02-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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);

Actions

Also available in: Atom PDF