Review main Merged

95102[TASK] Test QueryResult with objects instead of arrays

Oliver Klee CR +2 V +2 Easy +14 −12 updated 08/17/26, 10:43

Commit message

`QueryResult` iterates over objects, not over arrays.
Adapt the unit tests to use the correct types.

This was detected while adding native type declarations
to `QueryResult`.

Also tighten some assertions in the test.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Daniel Gohlke +1
    • Sebastian Iffland +1
    • Josua Vogel +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Daniel Gohlke +1
    • Josua Vogel +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1821

  1. Oliver Klee uploaded patch set 1 08/04/26, 10:31

  2. Oliver Klee uploaded patch set 2 08/04/26, 10:34

  3. core-ci voted on patch set 1 V -1 08/04/26, 10:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105939

  4. core-ci voted on patch set 2 V +1 08/04/26, 10:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105940

  5. Sebastian Iffland voted on patch set 2 CR +1 08/04/26, 11:13

  6. Josua Vogel voted on patch set 2 CR +1 V +1 08/04/26, 12:03

  7. Garvin Hicking commented on patch set 2 08/04/26, 12:14

    But I think queryResult CAN work with array, so shouldn't we probably cover both scenarios? Otherwise if at some point the array dealing might break we wouldn't notice?
  8. Oliver Klee commented on patch set 2 08/04/26, 12:30

    Reply

    This is about the single result items in the query result, not about the set of items. The way I read the source code, `::first` and `::current()` are only intended to return either an object or `false`/`null`, but not an array: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Persistence/Generic/QueryResult.php#L197 Currently, returning arrays also works (at least when we mock things). I think this works "by accident" and not as promised functionality as we currently don't enforce the contract via native type declarations. As soon as we (i.e., I) add native type declarations, those unit tests break. The rest of Core tests all are green. This means that at least in the Core, `QueryResult` will is used to only return objects, not arrays.
  9. Garvin Hicking commented on patch set 2 08/04/26, 12:47

    Reply

    Thanks for explaining. I can't verify this right now and don't want to block things, so I'm resolving this!
  10. Simon Schaufelberger voted on patch set 2 CR +1 V +1 08/04/26, 21:22

  11. Georg Ringer voted on patch set 2 CR +1 V +1 08/05/26, 07:55

  12. Daniel Gohlke voted on patch set 2 CR +1 08/06/26, 18:28

  13. Daniel Gohlke voted on patch set 2 V +1 08/06/26, 19:01

  14. Oliver Klee uploaded patch set 3 CR +1 V +1 08/17/26, 08:05

  15. core-ci voted on patch set 3 V +1 08/17/26, 08:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106808

  16. Georg Ringer voted on patch set 3 CR +1 V +1 08/17/26, 08:14

  17. Daniel Gohlke voted on patch set 3 CR +1 V +1 08/17/26, 08:24

  18. Josua Vogel voted on patch set 3 CR +1 V +1 08/17/26, 09:14

  19. Sebastian Iffland voted on patch set 3 CR +1 08/17/26, 09:30

  20. Georg Ringer voted on patch set 3 CR +2 V +2 08/17/26, 10:43

  21. Georg Ringer merged patch set 4 08/17/26, 10:43