Bug #88886
openDataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling
0%
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()) {
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())
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").
Updated by Matthias Meusburger about 5 years ago
- Category changed from Extbase to Extbase + l10n
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
Updated by Matthias Meusburger about 5 years ago
- Has duplicate Bug #89132: DataMapper: Consider languageOverlayMode "hideNonTranslated" when getting relations using consistentTranslationOverlayHandling added
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
Updated by Mathias Brodala about 4 years ago
- Related to Bug #82363: Make Extbase translation handling consistent with typoscript added
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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');
}
}
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
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
Updated by Mathias Brodala 6 months ago
- Related to Feature #97926: Use LanguageAspect in Extbase Persistence added
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
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
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