Bug #88887

DataMapper: Don't pass language -1 to child query 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

Given:

The new feature "consistentTranslationOverlayHandling" is enabled.
There is an unlocalizable record (sys_language_uid = -1) which has a relation to a localizable record.

Problem:

At the moment the language of the parent record is passed to the relation's query to get correct overlays if e.g. the parent record's language doesn't equal the language of the parent query (page language).
However, this shouldn't be done, if the parent record's language is -1, because in this case we still want to use the language UID of the parent query. Otherwise $pageRepository->getRecordOverlay() in Typo3DbBackend::overlayLanguageAndWorkspace won't overlay the child record as expected.

Solution:

Don't do it if the language is -1.

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

444  444    protected function getPreparedQuery(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '')
445  445        {
446  446            $dataMap = $this->getDataMap(get_class($parentObject));
447  447            $columnMap = $dataMap->getColumnMap($propertyName);
448  448            $type = $this->getType(get_class($parentObject), $propertyName);
449  449            $query = $this->queryFactory->create($type);
450  450            if ($this->query && $query instanceof Persistence\Generic\Query) {
451  451                $query->setParentQuery($this->query);
452  452            }
453  453            $query->getQuerySettings()->setRespectStoragePage(false);
454  454            $query->getQuerySettings()->setRespectSysLanguage(false);
455  455    
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  461
462  462                    if ($dataMap->getLanguageIdColumnName() !== null && !$this->query->getQuerySettings()->getRespectSysLanguage()) {
463  463                        //pass language of parent record to child objects, so they can be overlaid correctly in case
464  464                        //e.g. findByUid is used.
465  465                        //the languageUid is used for getRecordOverlay later on, despite RespectSysLanguage being false
466  466                        $languageUid = (int)$parentObject->_getProperty('_languageUid');
467       -                     $query->getQuerySettings()->setLanguageUid($languageUid);
     467  +                     //Don't do it if the parent's language is "All" because language overlay wouldn't work anymore
     468  +                     if ($languageUid !== -1) {
     469  +                         $query->getQuerySettings()->setLanguageUid($languageUid);
     470  +                     }
468  471                    }
469  472                }
470  473            }


Related issues

Duplicated by TYPO3 Core - Bug #89133: DataMapper: Don't pass language -1 to child query using consistentTranslationOverlayHandling New 2019-08-01

History

#1 Updated by Matthias Meusburger about 1 month ago

  • Category changed from Extbase to Extbase + l10n

#2 Updated by Matthias Meusburger about 1 month ago

  • Subject changed from DataMapper: Don't pass language -1 to child query to DataMapper: Don't pass language -1 to child query using consistentTranslationOverlayHandling

#3 Updated by Matthias Meusburger about 1 month ago

  • Duplicated by Bug #89133: DataMapper: Don't pass language -1 to child query using consistentTranslationOverlayHandling added

Also available in: Atom PDF