72244[!!!][TASK] Harden method signature of logicalAnd() and logicalOr()
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Oli Bartsch +1
- Stefan Bürk +1
-
Verified V +2 Done
- Christian Kuhn +2
- Oli Bartsch +1
- Stefan Bürk +1
- core-ci +1 CI
Issues 1
Files 11
- typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php+4 −2
- typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php+12 −6
- typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96044-HardenMethodSignatureOfLogicalAndAndLogicalOr.rstnew+126 −0
- typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst+5 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/Exception/InvalidNumberOfConstraintsException.php3deleted+0 −27
- typo3/sysext/extbase/Classes/Persistence/Generic/Query.php+17 −67
- typo3/sysext/extbase/Classes/Persistence/QueryInterface.php+6 −10
- typo3/sysext/extbase/Tests/Functional/Persistence/RelationTest.php+6 −6
- typo3/sysext/extbase/Tests/Functional/Persistence/TranslationTest.php+7 −1
- typo3/sysext/extbase/Tests/Unit/Persistence/Generic/QueryTest.php+0 −134
- typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodArgumentRequiredMatcher.php+28 −0
Review log 2834
Show 69 earlier messages
-
Alexander Schnitzler uploaded patch set 1 11/21/21, 15:02
-
core-ci voted on patch set 1 V -1 11/21/21, 15:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19607
-
Alexander Schnitzler uploaded patch set 2 11/21/21, 15:24
-
core-ci voted on patch set 2 V +1 11/21/21, 15:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19608
-
Alexander Schnitzler uploaded patch set 3 11/21/21, 18:27
-
Alexander Schnitzler uploaded patch set 4 11/21/21, 18:35
-
Alexander Schnitzler commented on patch set 4 11/21/21, 18:36
-
Alexander Schnitzler wrote 11/21/21, 18:36
Topic set to extbase -
core-ci voted on patch set 3 V +1 11/21/21, 18:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19611
-
core-ci voted on patch set 4 V +1 11/21/21, 18:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19612
-
Christian Kuhn commented on patch set 4 CR -1 11/25/21, 09:30
temp -1 until we prepared the deprecation removals for v12. -
Tymoteusz Motylewski commented on patch set 4 11/28/21, 20:41
can you explain the benefit of this change either here or in the ticket? this change makes userland code more complex, so it would be great to have benefits more visible -
Benni Mack wrote 11/29/21, 10:22
Change destination moved from master to main -
Benni Mack updated the commit message in patch set 5 11/29/21, 14:11
-
Alexander Schnitzler commented on patch set 5 11/30/21, 14:07
Reply
It's actually described in the rst file, at least partly but here again: Both logicalAnd() and logicalOr() need at least two parameters to form a logical conjunction. Currently this is not guaranteed due to the acceptance of an array. If passed an array with a single element, that one is effectively just returned which makes it impossible to add a return type to those methods. Also, this method either accepted an array or any number of arguments via func_get_args(). IDE's like phpstorm never really knew if the arguments passed to said functions are correct. This change clears things up. There are at least two constraints needed, any number of additional constraints can be added. Yes, it makes working with methods a bit more tedious but it also prevents wrong usage for the sake of strict and dependable types. -
Tymoteusz Motylewski commented on patch set 5 12/03/21, 09:21
Does it makes sense and is doable to provide additional API to lower the migration buden? -
Stefan Bürk commented on patch set 5 12/06/21, 15:21
Reply
Instead of switching to two parameters and than the array expension thing ... why not only used a typed array expension thing, and simple do a count and if count is not >= 2, throw an invalid argument count exception or something like that. Migration would be than simple removing the array brackets, without needed to do that hackish and complex array shift and check code. ``` $constraints = []; if (...) { $constraints[] = $query->equals('propertyName1', 'value1'); } if (...) { $constraints[] = $query->equals('propertyName2', 'value2'); } $query = $this->createQuery(); $numberOfConstraints = count($constraints); if ($numberOfConstraints === 1) { $query->matching(reset($constraints)); } elseif ($numberOfConstraints >= 2) { $query->matching($query->logicalAnd( ...$constraints )); } ``` or with a try catch approach (if someone prefers that): ``` try { $query->matching($query->logicalAnd( ...$constraints )); } catch(OurConcreteLogicalAndCountNotEnoughException) $query->matching(reset($constraints)); } ``` And then this as method signiature (with throwing exception if count is not at least 2 - at best not a generic one, but a more concrete): ``` public function logicalAnd(ConstraintInterface ...$furtherConstraints): AndInterface ``` -
Alexander Schnitzler commented on patch set 5 12/06/21, 15:52
Reply
I don't care any more what we do here. Please just decide something, folks. Keep in mind we need to patch the interface in 10 and 11 as well then because those versions already received patches in this direction. See https://review.typo3.org/c/Packages/TYPO3.CMS/+/72144 -
Stefan Bürk commented on patch set 5 12/06/21, 16:30
Reply
Sry, it was just a question. Retought my question/suggestion - it was not my goal to offend you, but I could not get what was wrong to get you there, that you do not care anymore. Sry for that. Anyway, still using your implemented signature, maybe we may simply the example in the rest file, as this should work even with your signature of these methods: ``` $numberOfConstraints = count($constraints); if ($numberOfConstraints === 1) { $query->matching(reset($constraints)); } elseif ($numberOfConstraints >= 2) { $query->matching($query->logicalAnd( ...$constraints )); } ``` As your goal was to harden the type of the first two parameters, I would add at least that type for the third to. As such they would be typed too. ``` public function logicalAnd(ConstraintInterface $constraint1, ConstraintInterface $constraint2, ConstraintInterface ...$furtherConstraints): AndInterface ``` What do you think ? -
Alexander Schnitzler commented on patch set 5 12/06/21, 22:14
Reply
Don’t worry, you didn’t offen me at all. It’s simply stressful because we had that mentioned change some weeks ago and nobody had any doubts back then. I see the problems with those fixed arguments but I also see the work to get this straight in 3 versions now. All I want to express is that I really don’t care about any specific implementation. I just don’t to get things done. :) -
Alexander Schnitzler commented on patch set 5 12/06/21, 22:15
Reply
„want“, not „don’t“ -
Christian Kuhn commented on patch set 5 CR -1 12/07/21, 15:03
i'll play around here and will probably push soon. -
Stefan Bürk uploaded patch set 6 12/07/21, 19:17
-
Stefan Bürk uploaded patch set 7 12/07/21, 19:26
-
core-ci voted on patch set 6 V +1 12/07/21, 19:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20747
-
Stefan Bürk voted on patch set 7 V +1 CR +1 12/07/21, 19:31
-
Christian Kuhn voted on patch set 7 V +1 CR +1 12/07/21, 19:31
-
core-ci voted on patch set 7 V +1 12/07/21, 19:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20748
-
Christian Kuhn commented on patch set 7 12/07/21, 19:38
Reply
DoneInvalidNumberOfConstraintsException.php:25Replyjust remove. three is little point to keep that exception now. -
Christian Kuhn commented on patch set 7 12/07/21, 19:39
InvalidNumberOfConstraintsException.php:25ReplyDone -
Oli Bartsch voted on patch set 7 V +1 CR +1 12/07/21, 19:52
-
Christian Kuhn voted on patch set 7 V +2 CR +2 12/07/21, 19:52
-
Christian Kuhn merged patch set 8 12/07/21, 19:52
-
Markus Klein commented on patch set 8 09/22/22, 11:26
InvalidNumberOfConstraintsException.php:25