Review 13.4 Merged

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

Garvin Hicking CR +2 V +2 Normal +168 −2 updated 11/07/24, 07:20

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
  • Verified V +2 Done
    • Garvin Hicking +2
    • core-ci +1 CI

Issues 2

Files 5

Review log 34

  1. Garvin Hicking commented on patch set 1 11/07/24, 07:02

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 11/07/24, 07:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69170

  3. Garvin Hicking voted on patch set 1 CR +2 V +2 11/07/24, 07:20

  4. Garvin Hicking merged patch set 2 11/07/24, 07:20