Verified Commit 465b5b44 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3180588 by GuyPaddock, zeeshan_khan, vsujeetkumar, bnjmnm, tstoeckler:...

Issue #3180588 by GuyPaddock, zeeshan_khan, vsujeetkumar, bnjmnm, tstoeckler: "Enforced" Dependencies of Optional Configs Overwrite Other Dependencies

(cherry picked from commit bab90f46)
parent d6f89f31
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Core\Config;

use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Extension\ExtensionPathResolver;
use Drupal\Core\Installer\InstallerKernel;
@@ -620,7 +621,7 @@ protected function getMissingDependencies($config_name, array $data, array $enab

      // Ensure enforced dependencies are included.
      if (isset($all_dependencies['enforced'])) {
        $all_dependencies = array_merge($all_dependencies, $data['dependencies']['enforced']);
        $all_dependencies = NestedArray::mergeDeep($all_dependencies, $data['dependencies']['enforced']);
        unset($all_dependencies['enforced']);
      }
      // Ensure the configuration entity type provider is in the list of
+13 −0
Original line number Diff line number Diff line
id: config_test.dynamic.enforced_and_base_dependencies
label: 'Module test with a mix of enforced and base modular dependencies'
weight: 0
style: ''
status: true
langcode: en
protected_property: Default
dependencies:
  enforced:
    module:
      - config_install_dependency_enforced_combo_test
  module:
    - readonly_field_widget
+4 −0
Original line number Diff line number Diff line
name: 'Config install dependency test with mix of enforced and base module dependencies'
type: module
package: Testing
version: VERSION
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,11 @@ public function testInstallOtherModuleFirst() {
    // recreated.
    $this->installModule('config');
    $this->assertNull($this->getStorage()->load('other_module_test_optional_entity_unmet'), 'The optional configuration config_test.dynamic.other_module_test_optional_entity_unmet whose dependencies are met is not installed when an unrelated module is installed.');

    // Ensure that enforced dependencies do not overwrite base ones.
    $this->installModule('config_install_dependency_enforced_combo_test');
    $this->assertTrue(\Drupal::moduleHandler()->moduleExists('config_install_dependency_enforced_combo_test'), 'The config_install_dependency_enforced_combo_test module is installed.');
    $this->assertNull($this->getStorage()->load('config_test.dynamic.enforced_and_base_dependencies'), 'The optional configuration config_test.dynamic.enforced_and_base_dependencies whose enforced dependencies are met but base module dependencies are not met is not created.');
  }

  /**