Commit 634e3a3f authored by Dries's avatar Dries

Issue #2171015 by alexpott: Drupal 8 HEAD broken: installing Language module...

Issue #2171015 by alexpott: Drupal 8 HEAD broken: installing Language module fails, after that cannot install any other module.
parent 2d093235
......@@ -2405,7 +2405,7 @@ function language_list($flags = Language::STATE_CONFIGURABLE) {
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
$languages = array();
$languages = array();
// Fill in master language list based on current configuration.
$default = language_default();
......@@ -2429,7 +2429,10 @@ function language_list($flags = Language::STATE_CONFIGURABLE) {
}
Language::sort($languages);
}
else {
// If the language module is enable but the configuration has not been
// written yet the returning an empty language list will cause errors. For
// example the cache clear in search_module_preinstall().
if (empty($languages)) {
// No language module, so use the default language only.
$languages = array($default->id => $default);
// Add the special languages, they will be filtered later if needed.
......
<?php
/**
* @file
* Contains \Drupal\language\Tests\LanguageListModuleInstallTest.
*/
namespace Drupal\language\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Functional tests for the language list configuration forms.
*/
class LanguageListModuleInstallTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language_test');
public static function getInfo() {
return array(
'name' => 'Language list during module install',
'description' => 'Tests enabling Language if a module exists that calls language_list during installation.',
'group' => 'Language',
);
}
/**
* Tests enabling Language.
*/
function testModuleInstallLanguageList() {
// Since language_list uses static caches we need to do this be enabling
// the module using a the UI.
$admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
$this->drupalLogin($admin_user);
$edit = array();
$edit['modules[Multilingual][language][enable]'] = 'language';
$this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
$this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using language_list() returns 1 language during Language installation.');
// Get updated module list by rebuilding container.
$this->rebuildContainer();
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('language'), 'Language module is enabled');
}
}
......@@ -128,3 +128,10 @@ function language_test_language_fallback_candidates_test_alter(array &$candidate
$candidates[$langcode] = $langcode;
}
}
/**
* Implements hook_module_preinstall().
*/
function language_test_module_preinstall() {
\Drupal::state()->set('language_test.language_count_preinstall', count(language_list()));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment