Review main Merged

72063[BUGFIX] Streamline arguments for logicalAnd() query in Extbase

Alexander Schnitzler CR +2 V +2 Normal +121 −8 updated 11/09/21, 16:09

Commit message

The method signature of Query::locicalAnd() is very misleading
because it only states there is one method argument $constraint1.

Actually, the method does accept any number of arguments, evaluated
via func_get_args(). It also accepts any number of arguments if
$constraint1 is an array of constraints. This leads to multiple
issues when working with phpstan and also when simply using an IDE
which does not understand the internal magic.

The goal is to state, that logicalAnd() needs at least two
constraints but also accepts any number of further constraints.

Since that requires a breaking change, the method signature can
only be fixed partly for now. $constraint1 remains as is, a 2nd
argument $constraint2 is introduced, null by default to make it
optional and a variadic argument ...$furtherConstraints is also
introduced.

This approach keeps the bc promise but also lays the foundation
for further changes in the next version.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1115

  1. Alexander Schnitzler uploaded patch set 1 11/05/21, 14:50

  2. Alexander Schnitzler wrote 11/05/21, 14:51

    Topic set to extbase
  3. Alexander Schnitzler uploaded patch set 2 11/05/21, 14:59

  4. core-ci voted on patch set 1 V +1 11/05/21, 15:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18952

  5. core-ci voted on patch set 2 V +1 11/05/21, 15:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18955

  6. Alexander Schnitzler uploaded patch set 3 11/06/21, 07:33

  7. Alexander Schnitzler updated the commit message in patch set 4 11/06/21, 07:35

  8. core-ci voted on patch set 3 V +1 11/06/21, 07:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18975

  9. core-ci voted on patch set 4 V +1 11/06/21, 07:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18976

  10. Oliver Klee commented on patch set 4 11/06/21, 10:54

    Query.php:404

    Do we need $constraint2 here, or could we directly use $furtherConstraints?
  11. Alexander Schnitzler commented on patch set 4 11/06/21, 11:52

    Query.php:404 Reply

    Yes, we do, because now, if only one constraint is mandatory, we cannot return a LogicalAndInterface but return the given Constraint which is wrong. A logical and needs at least two constraints in the future but allows for n more. The optionality of constraint2 will be removed in version 12.
  12. Oliver Klee commented on patch set 4 11/06/21, 15:11

    Thanks for the explanation!

    Query.php:404 Reply

    Ack
  13. Benni Mack voted on patch set 4 V +1 CR +1 11/09/21, 07:41

  14. Christian Kuhn voted on patch set 4 V +2 CR +2 11/09/21, 16:09

  15. Christian Kuhn merged patch set 5 11/09/21, 16:09