Review main Merged

90059[BUGFIX] Let Country object retrieval handle NULL value

Garvin Hicking CR +2 V +2 Easy +16 −2 updated 07/22/25, 06:21

Commit message

This fixes a PHP type error when saving a NULL value as
country object.

Can be reproduced by saving an EXT:styleguide entry of type
"elements - select" with default values (only fill in required
fields).

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Sebastian Iffland +1
    • Oliver Hader +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Oliver Klee +1
    • Oliver Hader +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 2429

Show 34 earlier messages
  1. Garvin Hicking uploaded patch set 1 07/13/25, 10:12

  2. core-ci voted on patch set 1 V +1 07/13/25, 10:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81655

  3. Oliver Klee commented on patch set 1 07/14/25, 07:52

    issue ID is still missing

    CountryProviderTest.php:55

    We can use `assertNull` instead.

    CountryProviderTest.php:57

    These should be two separate tests (one for null and one for the empty string).
  4. Garvin Hicking marked it work in progress 07/14/25, 08:22

  1. Garvin Hicking commented on patch set 1 07/14/25, 08:23

    Reply

    didnt flag as wip properly, thanks. Need to create the issue etc, caught this bug while working on sonething else
  2. Garvin Hicking uploaded patch set 2 V +1 07/14/25, 14:13

  3. Garvin Hicking commented on patch set 2 07/14/25, 14:14

    This change is ready for review.

    Reply

    Done

    CountryProviderTest.php:55 Reply

    Done

    CountryProviderTest.php:57 Reply

    Done
  4. core-ci voted on patch set 2 V +1 07/14/25, 14:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81692

  5. Oliver Klee commented on patch set 2 CR +1 V +1 07/14/25, 14:36

    13.4 is not affected?
  6. Garvin Hicking commented on patch set 2 07/14/25, 14:47

    Reply

    No, the "Country" object here is new with https://review.typo3.org/c/Packages/TYPO3.CMS/+/86177 and v14 only
  7. Sebastian Iffland commented on patch set 2 CR +1 V +1 07/14/25, 15:52

    CountryProvider.php:1748

    just a thought, but why not do an `empty($isoCode)` check? This way early return would also apply on empty string.
  8. Oliver Klee commented on patch set 2 07/14/25, 16:30

    CountryProvider.php:1748 Reply

    `empty` behaves in mysterious ways, e.g., the integer `0`, the string `0` or the bool `false` are empty as well. Hence, more explicit checks like this assure that there are no unwanted false positives.
  9. Sebastian Iffland commented on patch set 2 07/14/25, 16:36

    CountryProvider.php:1748 Reply

    You're right, remember TCA trouble due to same in https://github.com/typo3/typo3/commit/8ca71b977c9. So one could check for `if ($isoCode === null || trim($isoCode) === '') {` to perform early exit in this case.
  10. Sebastian Iffland commented on patch set 2 07/14/25, 16:39

    CountryProvider.php:1748 Reply

    Ah, wrong noted. Of course I meant before the BUGFIX commit empty created issues with `0`s, which made this necessary 😅
  11. Garvin Hicking commented on patch set 2 07/14/25, 16:42

    CountryProvider.php:1748 Reply

    Theoretically we could have a "default" country if we do not bail early on empty strings, so I'd like to keep that option and only bail early on a NULL isoCode...
  12. Oliver Hader commented on patch set 2 07/15/25, 07:28

    CountryProvider.php:1746

    Wouldn't it be better, to adjust the invocation to `getByIsoCode()`? Besides that, an additional comment what this method is doing would be great - in comparison to the other `getAlpha2IsoCode` and `getAlpha3IsoCode` methods.
  13. Garvin Hicking uploaded patch set 3 CR +1 V +1 07/16/25, 06:30

  14. Garvin Hicking uploaded patch set 4 07/16/25, 06:35

  15. Garvin Hicking commented on patch set 4 07/16/25, 06:36

    CountryProvider.php:1746 Reply

    I tried to phrase that. I'm not fully sure why Alpha2 and Alpha3 are both allowed here as a "lazy fallback", but I'm sure Benni had reasons in the initial commit. ;)
  16. core-ci voted on patch set 3 V -1 07/16/25, 06:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81763

  17. core-ci voted on patch set 4 V -1 07/16/25, 06:43 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81764

  18. Garvin Hicking uploaded patch set 5 V -1 07/16/25, 06:50

  19. core-ci voted on patch set 5 V +1 07/16/25, 06:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/81765

  20. Sebastian Iffland voted on patch set 5 CR +1 07/16/25, 07:03

  21. Oliver Klee voted on patch set 5 CR +1 V +1 07/16/25, 11:05

  22. Simon Schaufelberger voted on patch set 5 CR +1 V +1 07/17/25, 16:30

  23. Oliver Hader voted on patch set 5 CR +1 V +1 07/22/25, 06:17

  24. Garvin Hicking voted on patch set 5 CR +2 V +2 07/22/25, 06:21

  25. Garvin Hicking merged patch set 6 07/22/25, 06:21