Problem/Motivation
If a user installs Drupal using a non-English language and then adds English at a later time an error will appear on the admin/config page stating that "en" is undefined. This is caused by a line of code that removes English as one of the possible languages if it is not set to translatable. Since the user will not likely need to translate English, they may not enable translation of that language right away. At this place in the code the full list of languages is necessary.
The error message is: Undefined index: en in locale_requirements() (line 303 of core/modules/locale/locale.install) on /admin/config
Proposed resolution
Update the call to grab the full list of enabled languages.
Remaining tasks
Review the patch.
User interface changes
No
API changes
No
Related Issues
A test fails because it is checking the status page for text "not being there", so the provided patch updates the test to more appropriately test if the text IS there because that is what we are actually testing for. It is a proposed solution to a known issue referenced in #1882788: assertText/assertNoText doesn't really show what you could see in the browser (bad docs).
Steps to reproduce:
- Install Drupal in Dutch language (Nederlands). English is not installed.
- Go to admin/config
- there is no error
- add English as a language: error shows
Comment | File | Size | Author |
---|---|---|---|
#23 | 1998482.test-not-ready.23.patch | 3.36 KB | StryKaizer |
#12 | drupal-undefined-index-en-1998482-12.patch | 1.45 KB | Anonymous (not verified) |
#3 | drupal-undefined-index-en-1998482-3.patch | 542 bytes | Anonymous (not verified) |
Comments
Comment #1
tammo CreditAttribution: tammo commentedtagging
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedConfirmed this bug, I installed in French and added English after. Same result on admin/config
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedHere is a patch! The call to
locale_translatable_language_list();
was unsetting English if it is not set to translatable. In this case, we do not need to have English be translatable so the call has been updated to simply uselanguage_list();
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAdding sprint tag so this will show on the Drupal8multilingual.org focus page.
Comment #5
nonsieConfirmed the patch fixes the issue with site install in Estonian and adding English later.
Comment #6
pixeliteI've reproduced the error described in the issue and saw the error message.
Then, reviewed and tested the patch in #3. It removes the error.
Comment #8
nonsie#3: drupal-undefined-index-en-1998482-3.patch queued for re-testing.
Comment #10
Cameron Tod CreditAttribution: Cameron Tod commented#3: drupal-undefined-index-en-1998482-3.patch queued for re-testing.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedIt seems somehow this is triggering an existing bug #1882788: assertText/assertNoText doesn't really show what you could see in the browser (bad docs). Upon investigating it, it seems to make more sense to test if the status page HAS text rather than to test if it doesn't. This revised patch contains the revised test and passes local tests on my machine. Hopefully testbot feels the same way.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedI think my work here is done? Please review!
Comment #14
YesCT CreditAttribution: YesCT commentedtry looking at drupalcode.org to see the git blame for that assert no text line and see if we can find why it was a no text. Maybe there is some explaination in the issue that added it.
Comment #15
YesCT CreditAttribution: YesCT commentedthe issue summary is kind of blank. I think now we might know some more things to be added there.
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedThe commit references #1804702: Display interface translation status.
Comment #16.0
Anonymous (not verified) CreditAttribution: Anonymous commentedReformat to use summary template
Comment #16.1
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated issue summary.
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedI have updated the summary.
Comment #18
Gábor HojtsyYes, so this made that message show up because now the language list will always contain an item if English is the only language on the site and not enabled for translation. That I think is an edge case for having language module on, and should not in itself be a problem.
However we'd need tests to prove this bug/fix. I think its enough in the test to add a foreign language, remove English, add then visit the page from the test.
Comment #19
Gábor HojtsyTagging for D8MI.
Comment #20
StryKaizerWorking on testing
Comment #21
Gábor Hojtsy@StryKaizer: any updates?
Comment #22
StryKaizer@Gabor Hojtsy: Wrote tests which install french, set french as default site language, disabled and re-enabled english.
Debugged every step to ensure the tests are actually doing so, and confirmed they are doing what was needed, but error does not show up in my tests.
When I do the same thing manually (both in standard as minimal profile), the error does shows up.
I'm stuck here, anyone else willing to give it a try or a hint on what I'm missing?
Comment #23
StryKaizerAttached you'll find my attemp for the test, which failed to catch the error, see #22. Anyone willing to give this a try, or can give me a hint on how to fix this?
Comment #24
Gábor HojtsyLet's run the testbot at least with the proposed test :)
Comment #25
Gábor HojtsyI can manually reproduce the issue but not sure why the test would not do it. Seems entirely sensible that it would :/
Comment #26
helenkim CreditAttribution: helenkim commentedWhy these two lines included? Verbose message results "Access Denied"
Comment #27
YesCT CreditAttribution: YesCT commentedThe test in #23 installs in english, adds french, removes (not uninstalls) english, and then adds it back.
These are not the same steps as in the issue summary that says how to reproduce the error.
Maybe something related to
would help reproduce the steps.
Comment #28
StryKaizer#27 YesCT: They are indeed different from the issue summary, but my manual testing has proven they give the same error.
Comment #28.0
StryKaizerUpdated issue summary.
Comment #29
mgiffordComment #38
quietone CreditAttribution: quietone as a volunteer commentedUsing the steps in the Issue Summary I tested on Drupal 9.3.x, standard install using Italian and was not able to reproduce the problem.
Therefore, closing as cannot reproduce. If you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!