Commit 8a9f91ac authored by catch's avatar catch
Browse files

Issue #2831816 by Jo Fitzgerald, james.williams: Only first set of...

Issue #2831816 by Jo Fitzgerald, james.williams: Only first set of configuration dependencies is checked on installation
parent e9500065
...@@ -547,6 +547,7 @@ protected function validateDependencies($config_name, array $data, array $enable ...@@ -547,6 +547,7 @@ protected function validateDependencies($config_name, array $data, array $enable
* A list of missing config dependencies. * A list of missing config dependencies.
*/ */
protected function getMissingDependencies($config_name, array $data, array $enabled_extensions, array $all_config) { protected function getMissingDependencies($config_name, array $data, array $enabled_extensions, array $all_config) {
$missing = [];
if (isset($data['dependencies'])) { if (isset($data['dependencies'])) {
list($provider) = explode('.', $config_name, 2); list($provider) = explode('.', $config_name, 2);
$all_dependencies = $data['dependencies']; $all_dependencies = $data['dependencies'];
...@@ -574,12 +575,12 @@ protected function getMissingDependencies($config_name, array $data, array $enab ...@@ -574,12 +575,12 @@ protected function getMissingDependencies($config_name, array $data, array $enab
break; break;
} }
if (!empty($list_to_check)) { if (!empty($list_to_check)) {
return array_diff($dependencies, $list_to_check); $missing = array_merge($missing, array_diff($dependencies, $list_to_check));
} }
} }
} }
return []; return $missing;
} }
/** /**
......
...@@ -180,6 +180,10 @@ public function testUnmetDependenciesInstall() { ...@@ -180,6 +180,10 @@ public function testUnmetDependenciesInstall() {
// not depend on config_test and order is important. // not depend on config_test and order is important.
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test_language][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>'); $this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
$this->drupalPostForm('admin/modules', array('modules[Testing][config_other_module_config_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[Testing][config_other_module_config_test][enable]' => TRUE), t('Install'));
......
...@@ -61,6 +61,7 @@ public function testInstallOtherModuleFirst() { ...@@ -61,6 +61,7 @@ public function testInstallOtherModuleFirst() {
// installed once all the dependencies are met. // installed once all the dependencies are met.
$this->assertNull(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are not met is not created.'); $this->assertNull(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are not met is not created.');
$this->assertNull(entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are not met is not created.'); $this->assertNull(entity_load('config_test', 'other_module_test_optional_entity_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are not met is not created.');
$this->installModule('config_test_language');
$this->installModule('config_install_dependency_test'); $this->installModule('config_install_dependency_test');
$this->assertTrue(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are met is now created.'); $this->assertTrue(entity_load('config_test', 'other_module_test_unmet', TRUE), 'The optional configuration config_test.dynamic.other_module_test_unmet whose dependencies are met is now created.');
// Although the following configuration entity's are now met it is not // Although the following configuration entity's are now met it is not
......
...@@ -9,3 +9,5 @@ dependencies: ...@@ -9,3 +9,5 @@ dependencies:
enforced: enforced:
module: module:
- config_other_module_config_test - config_other_module_config_test
config:
- config_test.dynamic.dotted.english
...@@ -197,6 +197,16 @@ public function testDependencyChecking() { ...@@ -197,6 +197,16 @@ public function testDependencyChecking() {
$this->installModules(['config_install_dependency_test']); $this->installModules(['config_install_dependency_test']);
$this->fail('Expected UnmetDependenciesException not thrown.'); $this->fail('Expected UnmetDependenciesException not thrown.');
} }
catch (UnmetDependenciesException $e) {
$this->assertEqual($e->getExtension(), 'config_install_dependency_test');
$this->assertEqual($e->getConfigObjects(), ['config_test.dynamic.other_module_test_with_dependency' => ['config_other_module_config_test', 'config_test.dynamic.dotted.english']]);
$this->assertEqual($e->getMessage(), 'Configuration objects provided by <em class="placeholder">config_install_dependency_test</em> have unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
}
$this->installModules(['config_test_language']);
try {
$this->installModules(['config_install_dependency_test']);
$this->fail('Expected UnmetDependenciesException not thrown.');
}
catch (UnmetDependenciesException $e) { catch (UnmetDependenciesException $e) {
$this->assertEqual($e->getExtension(), 'config_install_dependency_test'); $this->assertEqual($e->getExtension(), 'config_install_dependency_test');
$this->assertEqual($e->getConfigObjects(), ['config_test.dynamic.other_module_test_with_dependency' => ['config_other_module_config_test']]); $this->assertEqual($e->getConfigObjects(), ['config_test.dynamic.other_module_test_with_dependency' => ['config_other_module_config_test']]);
......
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