Project

General

Profile

Feature #90079 » typo3_core_respect_language_all_when_generation_unique_slug.patch

Johannes Ender, 2020-01-10 08:30

View differences:

Classes/DataHandling/SlugHelper.php (date 1568188868694)
$this->applySlugConstraint($queryBuilder, $slug);
$this->applyPageIdConstraint($queryBuilder, $pageId);
$this->applyRecordConstraint($queryBuilder, $recordId);
$this->applyLanguageConstraint($queryBuilder, $languageId);
if ($languageId != -1) {
$this->applyLanguageConstraint($queryBuilder, [-1, $languageId]);
}
$this->applyWorkspaceConstraint($queryBuilder);
$statement = $queryBuilder->execute();
......
$queryBuilder = $this->createPreparedQueryBuilder();
$this->applySlugConstraint($queryBuilder, $slug);
$this->applyRecordConstraint($queryBuilder, $recordId);
$this->applyLanguageConstraint($queryBuilder, $languageId);
if ($languageId != -1) {
$this->applyLanguageConstraint($queryBuilder, [-1, $languageId]);
}
$this->applyWorkspaceConstraint($queryBuilder);
$statement = $queryBuilder->execute();
......
/**
* @param QueryBuilder $queryBuilder
* @param int $languageId
* @param int|array $languageId
*/
protected function applyLanguageConstraint(QueryBuilder $queryBuilder, int $languageId)
protected function applyLanguageConstraint(QueryBuilder $queryBuilder, $languageId)
{
$languageFieldName = $GLOBALS['TCA'][$this->tableName]['ctrl']['languageField'] ?? null;
if (!is_string($languageFieldName)) {
......
}
// Only check records of the given language
$queryBuilder->andWhere(
$queryBuilder->expr()->eq(
$languageFieldName,
$queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
)
);
if (is_array($languageId)) {
$queryBuilder->andWhere(
$queryBuilder->expr()->in(
$languageFieldName,
$queryBuilder->createNamedParameter($languageId, Connection::PARAM_INT_ARRAY)
)
);
} else {
$queryBuilder->andWhere(
$queryBuilder->expr()->eq(
$languageFieldName,
$queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
)
);
}
}
/**
(1-1/2)