Review main Merged

93512[BUGFIX] Avoid using null as array offset

Markus Klein CR +2 V +2 Easy +21 −14 updated 04/09/26, 18:36

Commit message

Do not access an array if the key is null.
This is deprecated in PHP and must be avoided.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 5

Review log 2734

Show 89 earlier messages
  1. Markus Klein uploaded patch set 1 04/01/26, 12:44

  2. Oliver Klee voted on patch set 1 CR +1 04/01/26, 12:45

  3. core-ci voted on patch set 1 V +1 04/01/26, 12:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99401

  4. Garvin Hicking commented on patch set 1 04/01/26, 19:34

    Did you find the instances manually or with some automatted check/rule?
  5. Markus Klein commented on patch set 1 04/01/26, 19:40

    Reply

    I found one of them in the logs (due to some playing around with my settings) and the rest with a simple search for "null]" ;-)
  6. Garvin Hicking commented on patch set 1 04/02/26, 08:17

    DatabaseRowDefaultAsReadonly.php:45

    I think this changes the intention. Now we check for a $result['databaseRow'][0] offset, and under some circumstances maybe that "0" could be filled. I think the whole condition would need to be refactored to check the array only in case a languageField is set. Or we would need to utilize a string like `__loremImpsumThisWillNeverHappenIAmSureOfIt` 😄

    BackendUtility.php:2243

    same here, checking for $MOD_MENU[$key][0] might access something in case we might have "0" as a valid key?

    ContentObjectRenderer.php:1567

    This is easier to showcase what I would write: ```suggestion if (isset($conf['fieldRequired'] ?? null) && !trim($this->data[$conf['fieldRequired']] ?? '')) { ```
  7. Markus Klein commented on patch set 1 CR -1 04/02/26, 11:17

    Yes, this was just an idea, maybe it's really better to go with proper conditions; I'll quickly update this
  8. Markus Klein uploaded patch set 2 CR +1 V +1 04/02/26, 13:41

  9. Markus Klein commented on patch set 2 04/02/26, 13:41

    DatabaseRowDefaultAsReadonly.php:45 Reply

    Done

    BackendUtility.php:2243 Reply

    Done

    ContentObjectRenderer.php:1567 Reply

    Done
  1. Oliver Klee commented on patch set 2 04/02/26, 13:52

    DatabaseRowDefaultAsReadonly.php:47

    Those are strings, not booleans. So let's make these checks more explicit by using `=== ''`.

    ContentObjectRenderer.php:1568

    ```suggestion if ($fieldName !== '' && trim($this->data[$fieldName] ?? '') !== '') { ```

    ImportExport.php:658

    Let's make this check more explicit as well.
  2. core-ci voted on patch set 2 V +1 04/02/26, 13:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99494

  3. Markus Klein uploaded patch set 3 V +1 04/02/26, 14:07

  4. Markus Klein commented on patch set 2 04/02/26, 14:07

    DatabaseRowDefaultAsReadonly.php:47 Reply

    Done

    ContentObjectRenderer.php:1568 Reply

    Done

    ImportExport.php:658 Reply

    Done
  5. Oliver Klee commented on patch set 3 04/02/26, 14:08

    ContentObjectRenderer.php:1568

    ```suggestion if ($fieldName !== '' && trim($this->data[$fieldName] ?? '') !== '') { ```
  6. core-ci voted on patch set 3 V +1 04/02/26, 14:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99501

  7. Stefan Bürk commented on patch set 4 V +1 04/02/26, 20:55

    Published edit on patch set 3.
  8. Stefan Bürk commented on patch set 4 04/02/26, 20:56

    ContentObjectRenderer.php:1568 Reply

    Fix applied.
  9. core-ci voted on patch set 4 V -1 04/02/26, 21:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99524

  10. Stefan Bürk commented on patch set 4 04/02/26, 21:26

    ContentObjectRenderer.php:1568 Reply

    Should have been `=== ''` instead of `!== ''`. However, now it's really interessting if the original check and behavor was really intented that way or not. Was it about ensuring that a value is set, which would mean `=== ''` is corred but not the failing test assumptions, or these assumption are right and needs to be `!== ''` here .....` (glad we applied it so it revealed that the orignal check was possible not that obvious as I/we possible has thought). See: https://3v4l.org/H1jsh
  11. Markus Klein commented on patch set 4 04/03/26, 10:25

    ContentObjectRenderer.php:1568 Reply

    The logic has to be: * if a "fieldRequired" is configured => check if a value is supplied * otherwise, do nothing
  12. Markus Klein commented on patch set 4 CR -1 04/03/26, 10:42

    Looking into it now
  13. Markus Klein uploaded patch set 5 CR -1 V -1 04/03/26, 10:57

  14. Markus Klein commented on patch set 5 04/03/26, 10:58

    ContentObjectRenderer.php:1568 Reply

    Done
  15. core-ci voted on patch set 5 V -1 04/03/26, 11:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99568

  16. Markus Klein commented on patch set 5 04/03/26, 14:36

    Op

    ContentObjectRenderer.php:1568

    Opinions wanted. The function comment says "when there is no content in the field given by fieldRequired" Until now, any false-ish field value ('', 0) has been treated as "no content". With our current implementation a "0" value will now be treated as "has content". Since I assume we really do not want to have a hidden breaking change here, I'd suggest to go back to the old boolean-operator.
  17. Markus Klein uploaded patch set 6 V -1 04/03/26, 14:41

  18. core-ci voted on patch set 6 V +1 04/03/26, 14:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99578

  19. Markus Klein uploaded patch set 7 V +1 04/09/26, 13:52

  20. Markus Klein commented on patch set 7 04/09/26, 13:52

    ContentObjectRenderer.php:1568 Reply

    Done
  21. core-ci voted on patch set 7 V +1 04/09/26, 14:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99856

  22. Stefan Bürk voted on patch set 7 CR +1 V +1 04/09/26, 14:40

  23. Garvin Hicking voted on patch set 7 CR +1 V +1 04/09/26, 15:41

  24. Stefan Bürk voted on patch set 7 CR +2 V +2 04/09/26, 18:35

  25. Stefan Bürk merged patch set 8 04/09/26, 18:36