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.
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | 2413191-38.patch | 4.13 KB | alexpott |
| #38 | 2413191-38.test-only.patch | 2.89 KB | alexpott |
| #38 | 31-38-interdiff.txt | 1.63 KB | alexpott |
| #31 | 2413191-31.interdiff.txt | 1.09 KB | claudiu.cristea |
| #31 | 2413191-31.patch | 3.37 KB | claudiu.cristea |
Comments
Comment #1
andyceo commentedComment #3
andyceo commentedSorry, was wrong patch.
Comment #4
andypostThere's
core/profiles/testing_multilingualprofile with languages that was added with tests in #2336743: When more than one language is added in the profile, the installer ignores thoseComment #6
andypostCore install stops because language module is not dependent on locale module
Major, because expected, needs discus a dependencies or document current behaviour
Comment #7
andyceo commentedComment #8
gábor hojtsy@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?
Comment #9
gábor hojtsyAdd tag to get help with manual testing.
Comment #10
keyral commentedMy step to test for erreur is :
Apply this patch
Install Drupal, to language and profile minimal.
For 4 testing install, no erreur in install.
Comment #13
gábor hojtsySo 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.
Comment #14
laszlo.kovacsThe 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.
Comment #15
gábor hojtsyWith the proposed patch it would still add the next batch operation (visible in the hunk).
Comment #18
dawehnerComment #19
andypostAlso there's issue with
drush si my_profile, if you choose--locale=deinstall of other languages from profile will be skipped (English as well)Comment #21
danepowell commentedThis prevents language imports from running during install if the local module is not enabled.
Comment #22
akoe commentedPatch #21 worked for me with 8.2.7 (and surprisingly did also apply \o/)
Comment #23
keyral commentedHi, this patch #21 is good for me.
Comment #27
jidrone commentedHi, the patch #21 worked for me.
Comment #28
claudiu.cristeaI confirm the bug. Attaching a "test only" patch.
Comment #30
claudiu.cristeaCompared to #21, my solution avoids using the module handler service. It just inspects the
$install_state['profile_info']['install']value.Comment #31
claudiu.cristeaIn fact #21 is correct. #30 doesn't work with Drush.
Comment #32
alexpottThis is a bit tricky - normally we force the locale module on for a multilingual install - see
install_profile_info()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.
Comment #33
claudiu.cristea@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.
Comment #34
justafishI'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.
Comment #35
pfrenssenI 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 ininstall_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 thelocalemodule 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
localemodule is enabled _after_ the above code frominstall_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 inInstallerTranslationTest.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.
Comment #36
alexpottI'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!
Comment #37
alexpottHmmm... 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.
Comment #38
alexpottComment #40
claudiu.cristeaThis has been once RTBCed in #35. I'm only reviewing the changes from #38.
Comment #42
alexpottCommitted 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.