Since TYPO3 v12 the use of constraints in the repository query is not working like before.
public function findByDate(
$dateFrom = null,
$dateTill = null,
$isAdmin = false,
$tags = [],
$keyword = ''
): QueryResultInterface
{
$query = $this->createQuery();
$query->getQuerySettings()->setIgnoreEnableFields(TRUE);
$query->getQuerySettings()->setEnableFieldsToBeIgnored(['starttime','endtime']);
$constraints = [];
if ($keyword != '') {
$constraints[] = $query->like('titel', '%'.$keyword.'%' );
}else{
if (isset($dateFrom) && isset($dateTill)) {
$constraints[] = $query->logicalAnd(
$query->lessThan('startdate', $dateTill->getTimestamp()),
$query->greaterThan('startdate', $dateFrom->getTimestamp()),
);
}
}
if (count($tags) > 0) {
$constraints[] = $query->logicalOr(
$query->in('tags.uid', $tags)
);
}
if ($isAdmin == false) {
$constraints[] = $query->equals('share', true);
}
$query->matching($query->logicalAnd($constraints));
return $query->execute();
}
Error
TYPO3\CMS\Extbase\Persistence\Generic\Query::logicalAnd(): Argument #1 must be of type TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface, array given
output of the constraints:
Is there still a way to use constraints?
- Query with one condition is working
- LogicalAnd with 2 constraints directly also works

The signature has changed. Instead of putting the array of constraints to logicalAnd() use the spread operator
....Replace
with
EDIT 1
Added
array_values()guard to avoid associative key unpacking with newer PHP versions.