Bug #88886

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

Added by Matthias Meusburger 3 months ago. Updated about 1 month ago.

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

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
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

Duplicated by TYPO3 Core - Bug #89132: DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling New 2019-08-01

History

#1 Updated by Matthias Meusburger 3 months ago

Backend.php:
Instead of if ($query->getQuerySettings()->getLanguageOverlayMode() !== 'hideNonTranslated') it could also be if (!$query->getQuerySettings()->getLanguageOverlayMode())

#2 Updated by Matthias Meusburger about 2 months ago

An example to illustrate the problem:

We have a product with 5 referenced features (multiselect via MM table, l10n_mode=exclude).
Only 4 of those 5 features are localized e.g. into German.

Without this fix the 5th unlocalized feature would also be there (in default language) although having set fallbackType="strict" (hideNonTranslated).
With the fix there will be only 4 features in German (as expected with "hideNonTranslated").

#3 Updated by Matthias Meusburger about 1 month ago

  • Category changed from Extbase to Extbase + l10n

#4 Updated by Matthias Meusburger about 1 month ago

  • Subject changed from DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations to DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling

#5 Updated by Matthias Meusburger about 1 month ago

  • Duplicated by Bug #89132: DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling added

Also available in: Atom PDF