Review main Merged

76761[BUGFIX] Avoid undefined array key access in LanguageMenuProcessor

J. Peter M. Schuler CR +2 V +2 Easy +1 −1 updated 11/23/22, 16:07

Commit message

While the assumption that sys_language_uid 0 is enabled is probably
always true, there are scenarios where this isn't the case (e.g.
disabling sys_language_uid 0 for different default languages on
different sites while still allowing cross-domain-links in the correct
language).

In PHP 7.4 the LanguageMenuProcessor did a graceful fallback to nothing,
in PHP 8.1 calling a LanguageMenuProcessor with disabled base language
results in an exception `Trying to access array offset on value of type
null`

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1619

  1. J. Peter M. Schuler uploaded patch set 1 11/21/22, 16:28

  2. Oliver Klee voted on patch set 1 CR +1 11/21/22, 16:29

  3. core-ci voted on patch set 1 V +1 11/21/22, 16:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34049

  4. Chris Müller voted on patch set 1 CR +1 11/21/22, 18:28

  5. Stefan Bürk commented on patch set 1 CR -1 11/22/22, 23:17

    Commit messages *must* not exceed a line length of 74 chars. Exception from that rule are basicly "external url/links" if they are needed, as reference or stuff like that. Or eventually full-namespace naming of classes. First line may be excepted also, in some situations. As this patch is "basicly" a default "undefined array key access" issue, the first line may be changed to: ``` [BUGFIX] Avoid undefined array key access in LanguageMenuProcessor ``` Beside this, the commit message can be left out with the suggested new first line, otherwise please reformat to NOT exceed the max of 74 per line. A more "block-styled" commit message is nice to see, but at least the max length should not be exceeded. And in this case it is 2x or 3x overlength.
  6. J. Peter M. Schuler uploaded patch set 2 CR +1 V +1 11/23/22, 00:19

  7. J. Peter M. Schuler commented on patch set 2 11/23/22, 00:20

    Reply

    Done. Sorry, something really went wrong during that push locally, I just checked this page on the top for the message and the CSS made it look correct.
  8. Stefan Bürk commented on patch set 2 V +1 CR +1 11/23/22, 00:26

    Reply

    Everything all-right. I decided to mention it, as I did not know if you were aware of this rule. And it was quite excessive. You may have a look into the core-contribution guide and look for the the `pre-commit hook` which is doing some checks (cgl). And I would tell you if you exceed this level. However, using GUI tools for commiting may not propery show this, as it does not contain a "exit code !== 0". But having that, commit message(change) would be lost if we throw that exit code. See: https://docs.typo3.org/m/typo3/guide-contributionworkflow/main/en-us/Appendix/CommitHook.html#pre-commit-hook However - thank you for taking care and adjusting it.
  9. core-ci voted on patch set 2 V +1 11/23/22, 00:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34092

  10. Chris Müller voted on patch set 2 CR +1 11/23/22, 05:24

  11. Oliver Klee voted on patch set 2 CR +1 11/23/22, 07:52

  12. Andreas Kienast commented on patch set 2 CR -1 11/23/22, 08:22

    LanguageMenuProcessor.php:470

    I'd rather do an early return here, as we need $language to be non-null at this point anyway.
  13. J. Peter M. Schuler uploaded patch set 3 CR +1 V +1 11/23/22, 14:24

  14. J. Peter M. Schuler commented on patch set 3 11/23/22, 14:26

    LanguageMenuProcessor.php:470 Reply

    Done. To be more clear an maintainable I'd propose `json_encode(null)` then, rather than `'{}'`. Although I would understand if core prefers the opposite.
  15. core-ci voted on patch set 3 V +1 11/23/22, 14:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/34114

  16. Oliver Klee voted on patch set 3 CR +1 11/23/22, 15:43

  17. Christian Kuhn voted on patch set 3 V +1 CR +1 11/23/22, 15:45

  18. Stefan Bürk voted on patch set 3 V +2 CR +2 11/23/22, 16:07

  19. Stefan Bürk merged patch set 4 11/23/22, 16:07