static call to getStandardLanguages() breaks service decorator

Created on 19 June 2023, almost 2 years ago
Updated 15 February 2024, about 1 year ago

Problem/Motivation

On line 154 of LanguageAddForm.php the $standard_languages is retrieved by a static call to LanguageManager::getStandardLanguageList();

When overriding the return value of getStandardLanguageList() via a service decorator, the added language appears in the drop-down list of languages to add but upon adding will not be present in the returned array as the static call bypasses any service decorators. This results in $label and $direction being undefined and a broken entry in the resulting table of enabled languages which cannot be removed.

Steps to reproduce

  1. Modify the return value of LanguageManager->getStandardLanguageList() to include an additional language with a service decorator.
  2. Select and add the new language via /admin/config/regional/language/add
  3. Observe broken entry in language list at /admin/config/regional/language

Proposed resolution

Use the injected languageManager service which is already available within the form.

Remaining tasks

  • Upload patch
πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Language systemΒ  β†’

Last updated 7 days ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024