Bug #102604
open
PersistedAliasMapper on translated extbase records wrong
Added by Lois Mula Fervenza 12 months ago.
Updated 2 months ago.
Category:
Site Handling, Site Sets & Routing
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.
Related issues
1 (1 open — 0 closed)
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;
}
- Related to Bug #102703: Persisted alias mapper should return item uid instead of languageParentFieldName when site translation fallbackType is set to free added
Also available in: Atom
PDF