Review main Merged

74388[BUGFIX] Fix undefined array key warning in TcaInline

Oli Bartsch CR +2 V +2 Easy +7 −5 updated 04/25/22, 19:40

Commit message

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Oliver Klee +1
    • Stefan Bürk +1
    • Nikita Hovratov +1
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Stefan Bürk +1
    • Nikita Hovratov +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1820

  1. Oli Bartsch uploaded patch set 1 04/25/22, 12:13

  2. core-ci voted on patch set 1 V +1 04/25/22, 12:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26399

  3. Stefan Bürk voted on patch set 1 CR +1 04/25/22, 12:35

  4. Oliver Klee commented on patch set 1 04/25/22, 12:38

    TcaInline.php:164

    The variable is used as an array key later on. As far as I know, only strings and ints are allowed as array keys. So the default value should be an empty string instead of null. (A string cast can't hurt either for cases where the TCA is invalid.)
  5. Stefan Bürk commented on patch set 1 04/25/22, 12:40

    TcaInline.php:164 Reply

  6. Stefan Bürk commented on patch set 1 04/25/22, 12:41

    TcaInline.php:164 Reply

    null is pretty fine here. no issue.
  7. Stefan Bürk voted on patch set 1 V +1 04/25/22, 12:42

  8. Oliver Klee commented on patch set 1 04/25/22, 12:44

    TcaInline.php:164 Reply

    According to https://www.php.net/manual/en/language.types.array.php, only strings and ints are allowed. Indeed, null seems to work. However, I'd prefer our code to stick to the specs instead of relying on undocumented behavior (which might break in newer PHP versions without deprecation).
  9. Oliver Klee commented on patch set 1 04/25/22, 12:46

    TcaInline.php:164 Reply

    Ah: > Additionally the following key casts will occur: > […] > Null will be cast to the empty string, i.e. the key null will actually be stored under "". I'd prefer our code to be explicit, i.e., to use "" directly. Then the reader does not need to know of this casting mechanism, and they then won't need to ask themselves why our code relied on the cast instead of using "" directly.
  10. Oliver Klee voted on patch set 1 CR -1 04/25/22, 12:47

  11. Stefan Bürk commented on patch set 1 04/25/22, 12:47

    TcaInline.php:164 Reply

    in a isset() it is pretty fine, as it checks for "not set". so it makes it obius that it should not be there. In the end, you may have places with a variable and checking with isset() or ?? if it is defined. you do not make a "type" caset or a type check before .. so using here null as default is fine (and expressive).
  12. Oliver Klee commented on patch set 2 04/25/22, 12:49

    Published edit on patch set 1.
  13. Oliver Klee commented on patch set 2 04/25/22, 12:51

    TcaInline.php:164 Reply

    I think we're mixing up two different things here (where $foo might be null): a) isset($foo) or $foo ?? … -> I'm perfectly fine with that b) isset($someArray($foo)) or $someArray($foo) ?? … -> I'm not so fine with that
  14. Oliver Klee voted on patch set 2 CR +1 04/25/22, 12:52

  15. core-ci voted on patch set 2 V +1 04/25/22, 12:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26400

  16. Stefan Bürk commented on patch set 2 V +1 CR +1 04/25/22, 13:01

    TcaInline.php:164 Reply

    Done
  17. Benni Mack voted on patch set 2 V +1 CR +1 04/25/22, 16:41

  18. Nikita Hovratov voted on patch set 2 V +1 CR +1 04/25/22, 17:11

  19. Oli Bartsch voted on patch set 2 V +2 CR +2 04/25/22, 19:40

  20. Oli Bartsch merged patch set 3 04/25/22, 19:40