Actions
Bug #88887
closedDataMapper: Don't pass language -1 to child query using consistentTranslationOverlayHandling
Status:
Closed
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:
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 }
Actions