Bug #102604
openPersistedAliasMapper on translated extbase records wrong
0%
Description
With a language configuration of fallbackType free, the translated extbase records are not found by the RouteEnhancer PersistedAliasMapper.
The reason for this is that the UID of the extbase record from the default language is used and therefore the wrong slug is used for routing.
As soon as the l10n_parent is removed in the translated extbase record, it works.
I currently have this problem with records from the News Extension.
Updated by Thomas Stranz 2 months ago
Lois Mula Fervenza wrote:
With a language configuration of fallbackType free, the translated extbase records are not found by the RouteEnhancer PersistedAliasMapper.
The reason for this is that the UID of the extbase record from the default language is used and therefore the wrong slug is used for routing.
As soon as the l10n_parent is removed in the translated extbase record, it works.
I currently have this problem with records from the News Extension.
I can confirm this behavior on TYPO3 12.4.20 with the following site config:
routeEnhancers:
News:
type: Extbase
extension: News
plugin: Pi1
routes:
-
routePath: '/{news-title}'
_controller: 'News::detail'
_arguments:
news-title: news
aspects:
news-title:
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
I could solve this for our project by overriding the resolveOverlay function in \TYPO3\CMS\Core\Routing\Aspect\PersistedAliasMapper via XCLASS
protected function resolveOverlay(?array $record): ?array
{
$languageId = $this->siteLanguage->getLanguageId();
if ($record === null || $languageId === 0) {
return $record;
}
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->tableName);
$qb->select(...$this->persistenceFieldNames)->from($this->tableName)
->where($qb->expr()->eq('l10n_parent', $record['uid']))
->andWhere($qb->expr()->eq('sys_language_uid', $languageId));
$overlay = $qb->executeQuery()->fetchAssociative();
if ($overlay) {
return $overlay;
}
return $record;
}
Updated by Thomas Stranz 2 months ago
- Related to Bug #102703: Persisted alias mapper should return item uid instead of languageParentFieldName when site translation fallbackType is set to free added