Project

General

Profile

Actions

Bug #88886

open

DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling

Added by Matthias Meusburger over 5 years ago. Updated about 1 month ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2019-08-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

The language overlay handling doesn't work properly using the new "consistentTranslationOverlayHandling" when getting DB relations if the language overlay mode is "hideNonTranslated" (fallbackType: strict).

Problem:

At the moment the languageOverlayMode is always set to true as

we always want to overlay relations as most of the time they are stored in db using default lang uids

That's correct. However, if the configured language overlay mode is "hideNonTranslated" (fallbackType: strict), we need to consider this.
Otherwise, if there's no translation, the default relation/row isn't removed in sysext/frontend/Classes/Page/PageRepository.php:790 (v9) resp. sysext/core/Classes/Domain/Repository/PageRepository.php:628 (v10) (called by $pageRepository->getRecordOverlay() in Typo3DbBackend::overlayLanguageAndWorkspace).

Solution:

1. Consider "hideNonTranslated" already when creating the parent object's query, so it can be passed to the sub query later on.

sysext/extbase/Classes/Persistence/Generic/Backend.php:

275  275    public function getObjectByIdentifier($identifier, $className)
276  276    {
277  277        if ($this->session->hasIdentifier($identifier, $className)) {
278  278            return $this->session->getObjectByIdentifier($identifier, $className);
279  279        }
280  280        $query = $this->persistenceManager->createQueryForType($className);
281  281        $query->getQuerySettings()->setRespectStoragePage(false);
282  282        $query->getQuerySettings()->setRespectSysLanguage(false);
283       -     $query->getQuerySettings()->setLanguageOverlayMode(true);
     283  +     if ($query->getQuerySettings()->getLanguageOverlayMode() !== 'hideNonTranslated') {
     284  +         $query->getQuerySettings()->setLanguageOverlayMode(true);
     285  +     }
284  286        return $query->matching($query->equals('uid', $identifier))->execute()->getFirst();
285  287    }

2. Pass "hideNonTranslated" to sub query.

sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php:

456  456    if ($this->configurationManager->isFeatureEnabled('consistentTranslationOverlayHandling')) {
457  457        //we always want to overlay relations as most of the time they are stored in db using default lang uids
458  458        $query->getQuerySettings()->setLanguageOverlayMode(true);
459  459        if ($this->query) {
460  460            $query->getQuerySettings()->setLanguageUid($this->query->getQuerySettings()->getLanguageUid());
     461  +         if ($this->query->getQuerySettings()->getLanguageOverlayMode() === 'hideNonTranslated') {
     462  +             $query->getQuerySettings()->setLanguageOverlayMode('hideNonTranslated');
     463  +         }
461  464    
462  465            if ($dataMap->getLanguageIdColumnName() !== null && !$this->query->getQuerySettings()->getRespectSysLanguage()) {


Related issues 4 (1 open3 closed)

Related to TYPO3 Core - Bug #89131: Records that are only available in specific language (no default parent) are not considered using consistentTranslationOverlayHandlingNew2019-09-10

Actions
Related to TYPO3 Core - Bug #82363: Make Extbase translation handling consistent with typoscriptClosedTymoteusz Motylewski2017-09-07

Actions
Related to TYPO3 Core - Feature #97926: Use LanguageAspect in Extbase PersistenceClosedBenni Mack2022-07-13

Actions
Has duplicate TYPO3 Core - Bug #89132: DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandlingClosedTymoteusz Motylewski2019-08-01

Actions
Actions

Also available in: Atom PDF