Review main Merged

86877[BUGFIX] Fix shorthand translation key handling in extbase validators

Torben Hansen CR +2 V +2 Normal +168 −2 updated 11/07/24, 07:21

Commit message

Since #102326 it is possible to customize extbase validation error
messages on validator basis.

With the change, all extbase validators were changed to use the
`LLL:` syntax for validation messages, adding an early return to
`translateErrorMessage()` in `AbstractValidator`, in order to
prevent messages not beginning with `LLL:` from being translated.

However, this did not respect a common scenario where the
`translateErrorMessage()` method was called with a shorthand
translation key (e.g. `validator.foo.message`) and an extension
name as second argument.

In this case, extbase `LocalizationUtility` would always use the
`locallang.xlf` file of the given extension name to lookup
possible translation keys.

This change fixes the problem by ensuring that
`translateErrorMessage()` always calls
`LocalizationUtility::translate()`, if an extension name is provided
as second argument to the method.

Tests are added to validate this behaviour.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Markus Klein +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 2

Files 5

Review log 810

  1. Torben Hansen uploaded patch set 1 11/04/24, 13:47

  2. core-ci voted on patch set 1 V +1 11/04/24, 13:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69037

  3. André Kraus voted on patch set 1 CR +1 11/04/24, 14:03

  4. Garvin Hicking updated the commit message in patch set 2 CR +1 V +1 11/04/24, 14:09

  5. Garvin Hicking voted on patch set 2 CR +1 V +1 11/04/24, 14:09

  6. core-ci voted on patch set 2 V +1 11/04/24, 14:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69038

  7. Markus Klein voted on patch set 2 CR +1 11/05/24, 07:44

  8. Simon Schaufelberger voted on patch set 2 CR +1 V +1 11/05/24, 08:08

  9. Garvin Hicking voted on patch set 2 CR +2 V +2 11/07/24, 07:21

  10. Garvin Hicking merged patch set 3 11/07/24, 07:21