In #2090115: Don't install a module when its default configuration has unmet dependencies we introduce the notion of optional configuration. When a module is installed all the config/optional directories are search for any configuration entities which have an entity type provided by the new module. This is the most basic dependency a module can have.

We can do better than this. We can determine if any optional configuration that does not exist has a dependency on the extension that is being installed and then create it if this condition is met. This means that modules can provide optional configuration the has multiple dependencies and it will be installed when all the dependencies are met.

For example, a module could provide a view which has a dependency on itself, Views and Block modules. The module itself does not have a dependency on Views or Block. It's installed before either of those modules. With HEAD if Block then Views is enabled the view will be created. If this occurred the other way around it would not be.

#4 2460847.4.patch9.82 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,708 pass(es). View
#4 1-4-interdiff.txt1.01 KBalexpott
#1 2460847.1.patch9.82 KBalexpott
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,589 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


alexpott’s picture

Status: Active » Needs review
Related issues: +#2460529: Migrations need to use the configuration entity dependency system
9.82 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,589 pass(es). View
rteijeiro’s picture

Status: Needs review » Reviewed & tested by the community

Code seems fine. Not sure how to manually test it.

Berdir’s picture

+++ b/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php
@@ -106,15 +106,10 @@ function testInstallProfileConfigOverwrite() {
+    // Installing db_log creates the optional configuration.
-    // Just installing db_log does not create the optional configuration.

db_log => dblog?

Tested this with monitoring, removed my custom code, only did some manual tests, but worked fine for them: #2461145: Remove custom optional config installation

alexpott’s picture

1.01 KB
9.82 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,708 pass(es). View

Addressing #3

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me, has ample test coverage and docs to explain what's happening. (It is an alexpott patch, after all! :D)

Committed and pushed to 8.0.x. Thanks!

  • webchick committed ccfaa23 on 8.0.x
    Issue #2460847 by alexpott: Allow optional configuration to be installed...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.