From 50f630431aae09515158846ca3c9b46c5290aa1d Mon Sep 17 00:00:00 2001
From: GoZ <goz@226961.no-reply.drupal.org>
Date: Tue, 24 Jan 2017 17:34:14 +0100
Subject: [PATCH] Issue #2816307 by GoZ: array_unique notice from List unmet
 configuration dependencies instead of just failing

---
 core/lib/Drupal/Core/Config/ConfigInstaller.php             |  2 +-
 ...onfig_test.dynamic.other_module_test_with_dependency.yml | 13 +++++++++++++
 ...test.dynamic.yet_another_module_test_with_dependency.yml | 13 +++++++++++++
 .../config_install_double_dependency_test.info.yml          |  5 +++++
 .../Drupal/KernelTests/Core/Config/ConfigInstallTest.php    |  9 +++++++++
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.other_module_test_with_dependency.yml
 create mode 100644 core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.yet_another_module_test_with_dependency.yml
 create mode 100644 core/modules/config/tests/config_install_double_dependency_test/config_install_double_dependency_test.info.yml

diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php
index 2f30cce..0da483c 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
@@ -457,7 +457,7 @@ public function checkConfigurationToInstall($type, $name) {
     // Check the dependencies of configuration provided by the module.
     list($invalid_default_config, $missing_dependencies) = $this->findDefaultConfigWithUnmetDependencies($storage, $enabled_extensions, $profile_storages);
     if (!empty($invalid_default_config)) {
-      throw UnmetDependenciesException::create($name, array_unique($missing_dependencies));
+      throw UnmetDependenciesException::create($name, $missing_dependencies);
     }
 
     // Install profiles can not have config clashes. Configuration that
diff --git a/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.other_module_test_with_dependency.yml b/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.other_module_test_with_dependency.yml
new file mode 100644
index 0000000..1d62266
--- /dev/null
+++ b/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.other_module_test_with_dependency.yml
@@ -0,0 +1,13 @@
+id: other_module_test_with_dependency
+label: 'Other module test with dependency'
+weight: 0
+style: ''
+status: true
+langcode: en
+protected_property: Default
+dependencies:
+  enforced:
+    module:
+      - config_other_module_config_test
+    config:
+      - config_test.dynamic.dotted.english
diff --git a/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.yet_another_module_test_with_dependency.yml b/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.yet_another_module_test_with_dependency.yml
new file mode 100644
index 0000000..c59c1e5
--- /dev/null
+++ b/core/modules/config/tests/config_install_double_dependency_test/config/install/config_test.dynamic.yet_another_module_test_with_dependency.yml
@@ -0,0 +1,13 @@
+id: yet_another_module_test_with_dependency
+label: 'Yet anther module test with dependency'
+weight: 0
+style: ''
+status: true
+langcode: en
+protected_property: Default
+dependencies:
+  enforced:
+    module:
+      - config_other_module_config_test
+    config:
+      - config_test.dynamic.dotted.english
diff --git a/core/modules/config/tests/config_install_double_dependency_test/config_install_double_dependency_test.info.yml b/core/modules/config/tests/config_install_double_dependency_test/config_install_double_dependency_test.info.yml
new file mode 100644
index 0000000..99404cf
--- /dev/null
+++ b/core/modules/config/tests/config_install_double_dependency_test/config_install_double_dependency_test.info.yml
@@ -0,0 +1,5 @@
+name: 'Config install double dependency test'
+type: module
+package: Testing
+version: VERSION
+core: 8.x
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
index dcd66a3..712d8d4 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
@@ -202,6 +202,15 @@ public function testDependencyChecking() {
       $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>');
     }
+    try {
+      $this->installModules(['config_install_double_dependency_test']);
+      $this->fail('Expected UnmetDependenciesException not thrown.');
+    }
+    catch (UnmetDependenciesException $e) {
+      $this->assertEqual($e->getExtension(), 'config_install_double_dependency_test');
+      $this->assertEqual($e->getConfigObjects(), ['config_test.dynamic.other_module_test_with_dependency' => ['config_other_module_config_test', 'config_test.dynamic.dotted.english'], 'config_test.dynamic.yet_another_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_double_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), config_test.dynamic.yet_another_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']);
-- 
2.8.1

