Problem/Motivation

Create an install profile with a language other than English. Depend the profile on language module. See patch on #3 basically. Using this profile to install in English, the installation ends up as PHP Fatal error: Call to undefined function locale_translation_use_remote_source() in /var/www/drupal/core/includes/install.core.inc on line 1695. This is due to install_import_translations() assuming if multiple languages are present, then locale module is present too. That is not necessarily true.

Proposed resolution

Only attempt to do the translation operations if locale module was an explicit or implicit dependency of the profile.

Remaining tasks

Fix. Add a new testing profile to test.

User interface changes

None.

API changes

None.

Comments

andyceo’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, language_bug.patch, failed testing.

andyceo’s picture

Status: Needs work » Needs review
StatusFileSize
new706 bytes

Sorry, was wrong patch.

andypost’s picture

Issue tags: +D8MI, +language-base

There's core/profiles/testing_multilingual profile with languages that was added with tests in #2336743: When more than one language is added in the profile, the installer ignores those

Status: Needs review » Needs work

The last submitted patch, 3: language_bug3.patch, failed testing.

andypost’s picture

Priority: Critical » Major
Status: Needs work » Needs review
StatusFileSize
new662 bytes
new670 bytes

Core install stops because language module is not dependent on locale module

$ git grep locale_translation_use_remote_source
core/includes/install.core.inc:1695:      if (locale_translation_use_remote_source()) {
core/modules/locale/locale.compare.inc:207:  if (locale_translation_use_remote_source()) {
core/modules/locale/locale.fetch.inc:100:      if (locale_translation_use_remote_source()) {
core/modules/locale/locale.module:945:function locale_translation_use_remote_source() {
core/modules/locale/locale.translation.inc:439:    'use_remote' => locale_translation_use_remote_source(),
core/modules/locale/src/Form/TranslationStatusForm.php:252:    if (locale_translation_use_remote_source() && $remote_path && $local_path) {

Major, because expected, needs discus a dependencies or document current behaviour

andyceo’s picture

Issue tags: +translation
gábor hojtsy’s picture

Issue tags: +medium

@andypost: But language module SHOULD NOT depend on locale, the dependency is the other way around. Neiher any calls in your grep are from language to locale. So that should not be a problem.

Can this still be reproduced?

gábor hojtsy’s picture

Issue tags: +Needs manual testing

Add tag to get help with manual testing.

keyral’s picture

My step to test for erreur is :

Apply this patch
Install Drupal, to language and profile minimal.

For 4 testing install, no erreur in install.

Status: Needs review » Needs work

The last submitted patch, 6: language_bug3_fix.patch, failed testing.

gábor hojtsy’s picture

Title: Fatal error when importing language with installation profile » Shipping a profile with multiple languages without locale module not possible
Issue summary: View changes
Issue tags: -Needs manual testing +Needs tests

So the idea is install_profile_info() adds the locale module as an automatic dependency on the profile if the install was in a foreign language. Looks like you have multiple languages given that you install in English and install_import_translations() expects locale module to be available then. But it is not. We can skip these steps if locale module is not on the profile explicitly or implicitly.

laszlo.kovacs’s picture

StatusFileSize
new854 bytes

The reason of the error message is that we try to use a function from a module not added yet. In the attached patch we check first if the module is already loaded.

Edit: Unfortunately my patch doesn't solve the basic problem so just ignore it. The shortest way I think is just adding locale module beside language to the dependencies in install profile info.yml file.

gábor hojtsy’s picture

With the proposed patch it would still add the next batch operation (visible in the hunk).

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.

dawehner’s picture

Component: base system » install system
andypost’s picture

Also there's issue with drush si my_profile, if you choose --locale=de install of other languages from profile will be skipped (English as well)

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.

danepowell’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

This prevents language imports from running during install if the local module is not enabled.

akoe’s picture

Patch #21 worked for me with 8.2.7 (and surprisingly did also apply \o/)

keyral’s picture

Hi, this patch #21 is good for me.

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.

jidrone’s picture

Hi, the patch #21 worked for me.

claudiu.cristea’s picture

Issue tags: -D8MI, -language-base, -translation, -medium, -Needs tests
StatusFileSize
new2.13 KB

I confirm the bug. Attaching a "test only" patch.

Status: Needs review » Needs work

The last submitted patch, 28: 2413191-28-test-only.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new3.43 KB
new1.3 KB

Compared to #21, my solution avoids using the module handler service. It just inspects the $install_state['profile_info']['install'] value.

claudiu.cristea’s picture

StatusFileSize
new3.37 KB
new1.09 KB

In fact #21 is correct. #30 doesn't work with Drush.

alexpott’s picture

This is a bit tricky - normally we force the locale module on for a multilingual install - see install_profile_info()

$locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : [];

So what concerns me is that if you selected another language in the installer the install is going to work and locale is going to be installed. I'm wondering if we should change this condition to also check to see if the profile provides any non english configurable languages and if so, install locale.

claudiu.cristea’s picture

@alexpott, having multiple languages installed doesn’t necessary mean that we should have the locale module enabled. While selecting a non-English language to run the installer requires locale as this module is about UI localization and the installer needs translated UI strings. On our project we have this case: the site’s UI is only in English but we have some content translated in different languages. We don’t need ‘locale’, then why should be that module enabled? More: Why should we import UI translated strings that we’ll never use? I think the logic from the patch makes more sense: We don’t import UI translations if the module that handles UI translations is not enabled.

justafish’s picture

I'm in the same situation as @claudiu.cristea - I have multiple languages for content translation but don't want the locale module.
The solution in #31 worked great for me, thanks.

pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

I researched why the locale module is enabled in install_profile_info() and I can confirm it is required so that the installation procedure itself can be shown in the correct language when installing a profile in a language other than English.

Outside of testing there is only one call to install_profile_info() that passes the language code and this is located in install_load_profile() which is called as part of the installation procedure (install_drupal() -> install_begin_request()). If the installation is interactive, this will allow Drupal to show translated versions of the forms that ask the user's credentials, timezone etc. It needs the locale module for this.

Now if a non-interactive installation of a profile is done (e.g. drush si my_profile) then we do not need to show translated forms, and locale is not needed.

The change introduced here is safe because it checks whether the locale module is enabled _after_ the above code from install_profile_info() is run. So if the locale module is required to display the installation forms in a different language, then it will be enabled and everything will work as expected. I checked we have coverage for this case and it is covered in InstallerTranslationTest.

I reviewed the fix and the test and both look good. Failing test can be found in #2413191-28: Shipping a profile with multiple languages without locale module not possible.

alexpott’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

I've credited @Gábor Hojtsy for code review and suggesting the correct fix and @pfrenssen for a good rtbc comment.

Committed and pushed 08183b22a3 to 8.8.x and 6cd7a078da to 8.7.x. Thanks!

alexpott’s picture

Status: Fixed » Needs work

Hmmm... didn't push - the new test is going to fail because it extends InstallerTest but does not override \Drupal\FunctionalTests\Installer\InstallerTest::testInstaller() so it's in effect running two tests. I've queued up a retest of the old patch against 8.8.x to prove this. I'm currently fixing this.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.63 KB
new2.89 KB
new4.13 KB

The last submitted patch, 38: 2413191-38.test-only.patch, failed testing. View results

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

This has been once RTBCed in #35. I'm only reviewing the changes from #38.

  • alexpott committed d37aea0 on 8.8.x
    Issue #2413191 by claudiu.cristea, alexpott, andyceo, andypost, laszlo....
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed d37aea09c0 to 8.8.x and 670f162640 to 8.7.x. Thanks!

As I only made very minor changes to the test and not runtime code I think it's okay for me to commit this.

Backported to 8.7.x as a non-disruptive major bug fix.

  • alexpott committed 670f162 on 8.7.x
    Issue #2413191 by claudiu.cristea, alexpott, andyceo, andypost, laszlo....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.