Actions
Bug #98456
closedSlug generation for language ID -1
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
Start date:
2022-09-28
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
slug
Complexity:
easy
Is Regression:
Sprint Focus:
Description
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:
/**
* @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)
)
)
);
}
Actions