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 #1

Updated by Matthias Meusburger over 5 years ago

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

Actions #2

Updated by Matthias Meusburger about 5 years 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").

Actions #3

Updated by Matthias Meusburger about 5 years ago

  • Category changed from Extbase to Extbase + l10n
Actions #4

Updated by Matthias Meusburger about 5 years ago

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

Updated by Matthias Meusburger about 5 years ago

  • Has duplicate Bug #89132: DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling added
Actions #6

Updated by Mathias Brodala about 4 years ago

  • Related to Bug #89131: Records that are only available in specific language (no default parent) are not considered using consistentTranslationOverlayHandling added
Actions #7

Updated by Mathias Brodala about 4 years ago

  • Related to Bug #82363: Make Extbase translation handling consistent with typoscript added
Actions #8

Updated by Gerrit Code Review about 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #9

Updated by Gerrit Code Review about 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #10

Updated by Gerrit Code Review about 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #11

Updated by Gerrit Code Review about 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #12

Updated by Gerrit Code Review about 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #13

Updated by Gerrit Code Review about 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #14

Updated by Mathias Brodala about 4 years ago

  • Is Regression set to Yes
Actions #15

Updated by Gerrit Code Review about 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #16

Updated by Gerrit Code Review about 4 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #17

Updated by Gerrit Code Review about 4 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #18

Updated by Gerrit Code Review about 4 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #19

Updated by Gerrit Code Review about 4 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #20

Updated by Gerrit Code Review almost 4 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #21

Updated by Gerrit Code Review over 3 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #22

Updated by Gerrit Code Review over 3 years ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #23

Updated by Alexander Vogt over 3 years ago

We have the same issue (TYPO3 9 / 10). Currently we use the following workaround via the "ModifyQueryBeforeFetchingObjectDataEvent" event:

class ModifyQueryBeforeFetchingObjectDataListener
{
  public function __invoke(ModifyQueryBeforeFetchingObjectDataEvent $event): void
  {
    $parentQuery = $event->getQuery()->getParentQuery();

    if(empty($parentQuery))
    {
      return;
    }

    $event->getQuery()->getQuerySettings()->setLanguageOverlayMode('hideNonTranslated');
  }
}
Actions #24

Updated by Gerrit Code Review about 3 years ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #25

Updated by Gerrit Code Review almost 3 years ago

Patch set 16 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #26

Updated by Mathias Brodala 6 months ago

  • Related to Feature #97926: Use LanguageAspect in Extbase Persistence added
Actions #27

Updated by Gerrit Code Review 6 months ago

Patch set 17 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #28

Updated by Gerrit Code Review 6 months ago

Patch set 18 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions #29

Updated by Gerrit Code Review about 1 month ago

Patch set 19 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66694

Actions

Also available in: Atom PDF