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

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:

  1. Install Drupal in Dutch language (Nederlands). English is not installed.
  2. Go to admin/config
  3. there is no error
  4. add English as a language: error shows
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tammo’s picture

Issue tags: +D8MI

tagging

Anonymous’s picture

Confirmed this bug, I installed in French and added English after. Same result on admin/config

Anonymous’s picture

Assigned: Unassigned »
Status: Active » Needs review
FileSize
542 bytes

Here 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 use language_list();

Anonymous’s picture

Issue tags: +sprint

Adding sprint tag so this will show on the Drupal8multilingual.org focus page.

nonsie’s picture

Confirmed the patch fixes the issue with site install in Estonian and adding English later.

pixelite’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
71.33 KB

I've reproduced the error described in the issue and saw the error message.
Error message on config page

Then, reviewed and tested the patch in #3. It removes the error.

Status: Reviewed & tested by the community » Needs work
Issue tags: -D8MI, -sprint

The last submitted patch, drupal-undefined-index-en-1998482-3.patch, failed testing.

nonsie’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal-undefined-index-en-1998482-3.patch, failed testing.

Cameron Tod’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +D8MI, +sprint

The last submitted patch, drupal-undefined-index-en-1998482-3.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review
FileSize
1.45 KB

It 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.

Anonymous’s picture

Assigned: » Unassigned

I think my work here is done? Please review!

YesCT’s picture

try 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.

YesCT’s picture

the issue summary is kind of blank. I think now we might know some more things to be added there.

Anonymous’s picture

Anonymous’s picture

Issue summary: View changes

Reformat to use summary template

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

Anonymous’s picture

I have updated the summary.

Gábor Hojtsy’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Yes, 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.

Gábor Hojtsy’s picture

Issue tags: +language-base

Tagging for D8MI.

StryKaizer’s picture

Assigned: Unassigned » StryKaizer

Working on testing

Gábor Hojtsy’s picture

@StryKaizer: any updates?

StryKaizer’s picture

@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?

StryKaizer’s picture

Attached 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?

Gábor Hojtsy’s picture

Status: Needs work » Needs review
Issue tags: -sprint

Let's run the testbot at least with the proposed test :)

Gábor Hojtsy’s picture

I can manually reproduce the issue but not sure why the test would not do it. Seems entirely sensible that it would :/

helenkim’s picture

+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageEnglishToggleTest.php
@@ -0,0 +1,95 @@
+    $modulepath = 'admin/modules';
+    $this->drupalGet($modulepath);

Why these two lines included? Verbose message results "Access Denied"

YesCT’s picture

Status: Needs review » Needs work

The 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.

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.

Maybe something related to

class InstallerTest extends WebTestBase {

would help reproduce the steps.

StryKaizer’s picture

#27 YesCT: They are indeed different from the issue summary, but my manual testing has proven they give the same error.

StryKaizer’s picture

Issue summary: View changes

Updated issue summary.

mgifford’s picture

Assigned: StryKaizer » Unassigned

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative

Using 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!