Review main Merged

86690[BUGFIX] Immediately apply language changes in user setup

Andreas Kienast CR +2 V +2 Normal +59 −3 updated 10/25/24, 15:30

Commit message

The user setup module now emits an event that is immediately applied to
the document element by the user settings manager, without requring a
full backend reload.

The HTML attribute `lang` is written with a new value, along with the
`lang` attribute, if the language is right-to-left.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1821

  1. Andreas Kienast uploaded patch set 1 10/22/24, 14:05

  2. Andreas Kienast uploaded patch set 2 10/22/24, 14:06

  3. core-ci voted on patch set 1 V +1 10/22/24, 14:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68370

  4. core-ci voted on patch set 2 V +1 10/22/24, 14:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68371

  5. Andreas Kienast commented on patch set 2 V -1 10/23/24, 06:32

    Switching back from rtl -> ltr doesn't work for the content frame.
  6. Andreas Kienast uploaded patch set 3 V +1 10/23/24, 06:36

  7. Andreas Kienast commented on patch set 3 10/23/24, 06:38

    Reply

    Done
  8. Andreas Kienast uploaded patch set 4 10/23/24, 06:39

  9. core-ci voted on patch set 4 V +1 10/23/24, 06:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68426

  10. Simon Schaufelberger commented on patch set 4 10/25/24, 12:04

    SetupModuleController.php:136

    !== null can be anything. Can we check specifically for a specific class with instanceof?
  11. Andreas Kienast commented on patch set 4 10/25/24, 12:08

    SetupModuleController.php:136 Reply

    No it cannot, the `LanguageService->getLocale()` is declared to return null or `Locale`.
  12. Simon Schaufelberger commented on patch set 4 10/25/24, 12:46

    SetupModuleController.php:136 Reply

    that is what I mean. check for `instanceof Locale::class`
  13. Andreas Kienast commented on patch set 4 10/25/24, 12:47

    SetupModuleController.php:136 Reply

    What's the benefit here? I think that's matter of taste.
  14. Simon Schaufelberger commented on patch set 4 10/25/24, 12:49

    SetupModuleController.php:136 Reply

    just by reading the code you know that you definitely have an object of Locale while with not null as I said it could be anything.
  15. Andreas Kienast commented on patch set 4 10/25/24, 12:55

    SetupModuleController.php:136 Reply

    > [...] it could be anything I get your point, but this is still a wrong assumption. What else could it be in theory, when the method is called `getLocale()` and treated as an object?
  16. Oli Bartsch commented on patch set 4 CR +1 V +1 10/25/24, 12:55

    SetupModuleController.php:136 Reply

    No, it can't be anything, that's what the return type is for. It's either NULL or Locale. We want this to be Locale so testing for NOT NULL is correct here.
  17. Simon Schaufelberger voted on patch set 4 CR +1 V +1 10/25/24, 13:14

  18. Benjamin Franzke voted on patch set 4 CR +2 V +2 10/25/24, 14:52

  19. Benjamin Franzke commented on patch set 4 10/25/24, 15:01

    SetupModuleController.php:136 Reply

    btw, this wrong (because it expresses pseudo uncertainty) usage of `instanceof` would have been forbidden by our custom phpstan `UnneededInstanceOfRule` check 😎 ``` Line setup/Classes/Controller/SetupModuleController.php ------ ------------------------------------------------------------------------------------------- 137 Unneeded instanceof on TYPO3\CMS\Core\Localization\Locale|null. Use a null check instead. ``` See: > 80859: [TASK] Add phpstan check for unneeded pseudo uncertain instanceof usage | https://review.typo3.org/c/Packages/TYPO3.CMS/+/80859
  20. Benjamin Franzke merged patch set 5 10/25/24, 15:01

  21. Simon Schaufelberger commented on patch set 5 10/25/24, 15:30

    SetupModuleController.php:136 Reply

    @ben@bnf.dev thank you for this link! That explains the reason very well why a null check is better than instanceof.