Bug #98456
Updated by Florian Leimer about 2 years ago
When creating an unique slug the language id is considered. At the moment there isn't any logic for the language id "-1" (all languages) and it is treated like any other language. This is a problem because it is possible that a record with a specific language and one with "all languages" can have the same slug.
I encountered this problem with EXT:news, where the routing wasn't able to get the correct uid.
My fix in \TYPO3\CMS\Core\DataHandling\SlugHelper:
<pre><code class="php">
/**
* @param QueryBuilder $queryBuilder
* @param int $languageId
*/
protected function applyLanguageConstraint(QueryBuilder $queryBuilder, int $languageId)
{
$languageFieldName = $GLOBALS['TCA'][$this->tableName]['ctrl']['languageField'] ?? null;
if (!is_string($languageFieldName)) {
return;
}
if ($languageId === -1) {
return;
}
// Only check records of the given language
$queryBuilder->andWhere(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->eq(
$languageFieldName,
$queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
$languageFieldName,
$queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)
)
)
);
}
</code></pre>