diff --git a/core/includes/install.inc b/core/includes/install.inc index be380ae1a43..533a9b52cd0 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1045,7 +1045,7 @@ function drupal_check_module($module) { function install_profile_info($profile, $langcode = 'en') { $cache = &drupal_static(__FUNCTION__, array()); - if (!isset($cache[$profile])) { + if (!isset($cache[$profile][$langcode])) { // Set defaults for module info. $defaults = array( 'dependencies' => array(), @@ -1067,9 +1067,9 @@ function install_profile_info($profile, $langcode = 'en') { $info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale)); - $cache[$profile] = $info; + $cache[$profile][$langcode] = $info; } - return $cache[$profile]; + return $cache[$profile][$langcode]; } /** diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php index b70edabd64b..05be03bd952 100644 --- a/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerLanguageTest.php @@ -42,4 +42,22 @@ class InstallerLanguageTest extends KernelTestBase { } } + /** + * Tests profile info caching in non-English languages. + */ + function testInstallerTranslationCache() { + require_once 'core/includes/install.inc'; + + // Prime the drupal_get_filename() static cache with the location of the + // testing profile as it is not the currently active profile and we don't + // yet have any cached way to retrieve its location. + // @todo Remove as part of https://www.drupal.org/node/2186491 + drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml'); + + $info_en = install_profile_info('testing', 'en'); + $info_nl = install_profile_info('testing', 'nl'); + + $this->assertFalse(in_array('locale', $info_en['dependencies']), 'Locale is not set when installing in English.'); + $this->assertTrue(in_array('locale', $info_nl['dependencies']), 'Locale is set when installing in Dutch.'); + } }