Review main Merged

75941[BUGFIX] Build LanguageService in TranslateViewHelper

Andreas Kienast CR +2 V +2 Easy +15 −2 updated 10/02/22, 19:17

Commit message

Since #98377, the request passed to Fluid's rendering context is no
`ExtbaseRequestInterface` anymore by default, which has an impact on the
`f:translate` view helper. The view helper checks whether the request is
a ExtbaseRequestInterface and falls back to Extbase's internal language
setup.

This patch extends the view helper's `getLanguageService()` method to
check whether the `LanguageService` is already built. If not, a
`LanguageService` is built depending on the application context.

Review

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

Issues 2

Files 1

Review log 1317

  1. Andreas Kienast uploaded patch set 1 10/02/22, 14:58

  2. Andreas Kienast uploaded patch set 2 10/02/22, 14:59

  3. Stefan Bürk commented on patch set 2 10/02/22, 15:02

    TranslateViewHelper.php:225

    Should we not use ``` $GLOBALS['BE_USER'] ?? null ``` to absolutly sure - what do you think ?
  4. Andreas Kienast commented on patch set 2 10/02/22, 15:04

    TranslateViewHelper.php:225 Reply

    Ack
  5. Andreas Kienast uploaded patch set 3 10/02/22, 15:04

  6. core-ci voted on patch set 2 V +1 10/02/22, 15:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31886

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

  8. core-ci voted on patch set 1 V +1 10/02/22, 15:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31885

  9. Chris Müller commented on patch set 3 10/02/22, 15:18

    TranslateViewHelper.php:216

    Why setting $GLOBALS['LANG'] and not returning early? This also avoids the unsexy if-else construct. Also, setting the global variable in this context may have side effects?

    TranslateViewHelper.php:220

    Here too.

    TranslateViewHelper.php:222

    Here too.
  10. Andreas Kienast commented on patch set 3 10/02/22, 15:25

    TranslateViewHelper.php:216 Reply

    IMO it's more "unappealing" to set GLOBALS/lang and return it directly again. The construction of LanguageService itself could be moved to a separate method, which solves the concern. I set GLOBALS/lang for performance reasons to avoid unnecessary reconstruction of the "same" LanguageService with every invocation of the view helper.
  11. Stefan Bürk uploaded patch set 4 10/02/22, 16:03

  12. Chris Müller commented on patch set 4 10/02/22, 16:12

    TranslateViewHelper.php:216 Reply

    Ack

    TranslateViewHelper.php:220 Reply

    Done

    TranslateViewHelper.php:222 Reply

    Done
  13. core-ci voted on patch set 4 V +1 10/02/22, 16:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/31890

  14. Stefan Bürk voted on patch set 4 V +1 CR +1 10/02/22, 16:31

  15. Georg Ringer voted on patch set 4 V +1 CR +1 10/02/22, 18:31

  16. Georg Ringer voted on patch set 4 V +2 CR +2 10/02/22, 19:17

  17. Georg Ringer merged patch set 5 10/02/22, 19:17