Problem/Motivation
After saving the language overview form, languages sometimes end up with incorrect name translations.
Steps to reproduce
- On an English site, add a Spanish
- Visit /en/admin/config/regional/language
- See language names are English and Spanish
- Visit /es/admin/config/regional/language
- Click Save
- Visit /en/admin/config/regional/language
- See language names are now Inglés and Español.
This affects the language switcher everywhere on the site
Proposed resolution
Load the language entities without overrides before saving them to ensure the untranslated entities are not polluted.
Issue fork language_hierarchy-3572656
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
bwaindwain commentedCreated merge request
Maybe related to https://www.drupal.org/project/language_hierarchy/issues/3355174
Comment #4
james.williamsOo this could be good, and yes, maybe it could solve #3355174: Native languanges aren't working, thank you! Is there any chance you could provide an automated test for this please, to demonstrate the issue & solution? Have you tried the patch on #3355174: Native languanges aren't working? It's not quite the same but looks to me be solving the same problem (so we shouldn't have both tickets open either). Your merge request does look more promising to me, as it doesn't treat language names as a special case in the config factory override class. (An automated test might also help us understand if that is still needed or not.)
---
Technical notes from my looking into this:
The language overview form is an extension of
ConfigEntityListBuilder. That base class usesloadMultipleOverrideFree()in itsload()method, butLanguageListBuilderoverrides that method to useloadByProperties(['locked' => FALSE])- so yes, overrides are unhelpfully included, which isn't normally correct for config entities.Comment #5
bwaindwain commentedI've never done a test for Drupal (yet...)
Comment #6
bwaindwain commentedtest output before fix:
after fix
OK (1 test, 1 assertion)Comment #7
james.williamsCongratulations on your first test then, thank you!
The a pipeline in gitlab which runs the tests also has an additional tests-only job; could you run that please to demonstrate it failing for the current code?
I’ll try again myself once I’m at work later, but I think only you have access to run it as it’s your MR. (Though there might be an option you can tick to let others run pipelines.)
Comment #9
james.williamsTurns out I did have permission to run that myself, and yep, it proves the bug. Thanks, great work!
Comment #11
bwaindwain commentedGreat! Kudos also to gemini and chatgpt for helping me with the test. ;)