Review main Merged

86302[BUGFIX] Properly evaluate EXT:indexed_search restriction by mediaType

Garvin Hicking CR +2 V +2 Normal +103 −7 updated 10/15/24, 05:19

Commit message

With refactorings in #102898 and #97412 the IndexSearchRepository
class property $mediaType was changed from a mixed type to
an integer, and later only integers were mapped to ENUM backed
values.

However, mediaType could always be not only an integer in range
of -2, -1 and 0 but also a string with a common file extension
like 'ppt' and so on.

This patch now allows both types (string and enum from int)
for proper search evaluation.

A functional test has been added to verify behaviour.

Review

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

Issues 3

Files 2

Review log 2027

Show 12 earlier messages
  1. Garvin Hicking uploaded patch set 1 09/24/24, 18:52

  2. core-ci voted on patch set 1 V -1 09/24/24, 18:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66513

  1. Garvin Hicking uploaded patch set 2 V -1 09/24/24, 19:22

  2. core-ci voted on patch set 2 V +1 09/24/24, 19:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66519

  3. Oli Bartsch commented on patch set 2 CR -1 09/24/24, 20:37

    -#

    IndexSearchRepository.php:164

    This will lead to an undefined array access in case $searchData does not contain `mediaType`

    IndexSearchRepository.php:166

    Let's check whether $searchData['mediaType'] is actually string - not just typecasting.

    IndexSearchRepository.php:777

    Why do we no longer access $this->mediaType directly?

    IndexSearchRepository.php:793

    I'm really not a big fan of mocking. However, is there a chance we can have some test without this new method and without changing the method visibility of `mediaTypeWhere`?

    IndexSearchRepositoryTest.php:113

    Please add the data provider above the test method.

    IndexSearchRepositoryTest.php:170

    I don't think we need a extra method for the single use in the new test.
  4. Garvin Hicking uploaded patch set 3 CR -1 V +1 09/25/24, 07:36

    address code review
  5. Garvin Hicking commented on patch set 3 09/25/24, 07:36

    Reply

    Done

    IndexSearchRepository.php:164 Reply

    Done

    IndexSearchRepository.php:166 Reply

    Done

    IndexSearchRepository.php:777 Reply

    Due to the introduction of the getter for the method I wanted to rely on the getter, and not route through direct access. In case we may want to utilize the getter in the future some more.

    IndexSearchRepository.php:793 Reply

    I didn't see another possibility to make it accessible within a test. I did not want to utilize the Reflection API to dynamically change visibility just for the test, but that is IMO the only option to prevent the public access. My personal thought is, since the class is internal, and getting the mediatype plus getting the raw SQL is a thing that should be available. But I'm very open to any suggestion. I don't "love" this myself.

    IndexSearchRepositoryTest.php:113 Reply

    Done

    IndexSearchRepositoryTest.php:170 Reply

    Done
  6. core-ci voted on patch set 3 V -1 09/25/24, 07:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66546

  7. Garvin Hicking uploaded patch set 4 V -1 09/25/24, 09:23

  8. core-ci voted on patch set 4 V +1 09/25/24, 09:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66561

  9. Oli Bartsch commented on patch set 4 09/25/24, 10:15

    IndexSearchRepository.php:793 Reply

    Oke but do we really need the getter? I mean we test the correct mediaType via the `$searchRepository->mediaTypeWhere()` already, right?
  10. Garvin Hicking commented on patch set 4 09/25/24, 11:37

    IndexSearchRepository.php:793 Reply

    In my test I wanted to match the resolved Enum properly, because I do some crude stuff to the SQL evaluation of what mediaTypeWhere() returns. Especially, because if the code in mediaTypeWhere will contain an error, we cannot catch this. So IMO we do not to match the mediaTypeWhere variable with an expectation.
  11. Stefan Bürk commented on patch set 4 CR -1 09/26/24, 09:56

    Will talk with garvin how to avoid making these public methods ...
  12. Garvin Hicking uploaded patch set 5 CR -1 V +1 09/30/24, 10:09

    Adjust test to use closure
  13. Garvin Hicking commented on patch set 5 09/30/24, 10:13

    Reply

    Done
    Refactored this with a closure bind to access the tested methods in the current scope, similar to the approach of https://review.typo3.org/c/Packages/TYPO3.CMS/+/86378
  14. Garvin Hicking commented on patch set 5 09/30/24, 10:14

    IndexSearchRepository.php:793 Reply

    Done
  15. core-ci voted on patch set 5 V +1 09/30/24, 10:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66849

  16. Garvin Hicking uploaded patch set 6 V +1 09/30/24, 16:42

    Change from closure to reflection like in other patch
  17. Garvin Hicking commented on patch set 6 09/30/24, 16:42

    I've now realigned this with the same approach as in https://review.typo3.org/c/Packages/TYPO3.CMS/+/86382 using reflection.
  18. Garvin Hicking commented on patch set 6 09/30/24, 16:43

  19. core-ci voted on patch set 6 V +1 09/30/24, 16:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66859

  20. Stefan Bürk voted on patch set 6 CR +1 V +1 10/14/24, 08:24

  21. Oli Bartsch uploaded patch set 7 CR +1 V +1 10/14/24, 18:48

  22. Oli Bartsch voted on patch set 7 CR +1 V +1 10/14/24, 18:48

  23. core-ci voted on patch set 7 V +1 10/14/24, 18:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67776

  24. Benni Mack voted on patch set 7 CR +2 V +2 10/15/24, 05:19

  25. Benni Mack merged patch set 8 10/15/24, 05:19