Breaking: #96044 - Harden method signature of logicalAnd() and logicalOr()

See forge#96044

Description

The method signature of \TYPO3\CMS\Extbase\Persistence\QueryInterface::logicalAnd() and \TYPO3\CMS\Extbase\Persistence\QueryInterface::logicalOr() has changed. As a consequence the method signature of \TYPO3\CMS\Extbase\Persistence\Generic\Query::logicalAnd() and \TYPO3\CMS\Extbase\Persistence\Generic\Query::logicalOr() has changed as well.

Both methods do no longer accept an array as first parameter.

Both methods do indeed accept an infinite number of further constraints.

The logicalAnd() method does now reliably return an instance of \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface instance while the logicalOr() method returns a \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface instance.

Impact

This change impacts all usages of said methods with just one array parameter containing all constraints.

Affected Installations

All installations that passed all constraints as array.

Migration

The migration is the same for logicalAnd() and logicalOr() since their method signature is the same. The upcoming example will show a migration for a logicalAnd() call.

Example:

$query = $this->createQuery();
$query->matching($query->logicalAnd([
    $query->equals('propertyName1', 'value1'),
    $query->equals('propertyName2', 'value2'),
    $query->equals('propertyName3', 'value3'),
]));
Copied!

In this case an array is used as one and only method argument. The migration is easy and quickly done. Simply don't use an array:

$query = $this->createQuery();
$query->matching($query->logicalAnd(
    $query->equals('propertyName1', 'value1'),
    $query->equals('propertyName2', 'value2'),
    $query->equals('propertyName3', 'value3'),
));
Copied!