Default configuration entities could depend on a module that is not installed.
The patch attached takes the following approach:
- All configuration in config/install has to have its dependencies met during install - if it does not then you get an unmet dependencies error.
- Optional configuration is moved to config/optional. During an extension's installation all configuration objects, whose dependencies can be met, are installed. This is a change from HEAD where we assume that config in config/install is optional if the config entity provider is not installed.
- When you install an extension that provides a config entity type (eg. views), all config/optional directories are searched for potential configuration to create. For example, when you install views, all views contained any installed extension's config/optional directories whose dependencies can be met are created.
As a result of these changes we can simplify a lot of the logic in ConfigInstaller because there is less magic detection of configuration to install. Also we get a nice performance boost in the installer because we are only searching optional configuration once per install rather than searching all the config/install directories for all installed modules during every module installation.
Steps to test
- Install minimal
- Uninstall the node module
- If testing the patch: move config/optional/views.view.frontpage.yml to config/install/views.view.frontpage.yml
Change the views.view.frontpage.yml (provided by node module) to have the following dependencies key:
This creates an unmet dependency
- Install node - With the patch, this should fail and an error message appear indicating that a dependency is missing for the view. With HEAD this will work
- Install views - this should work.
- Install node - With the patch, this should fail and an error message appear indicating that a dependency is missing for the view. With HEAD this will work and create a view that has unmet dependencies.
- Install telephone
- Install node - With the patch, this is work fine.
User interface changes
Message to user about missing dependencies for configuration.
EXTENSION/config/optionalfor optional configuration to install during module installation
ConfigInstaller::findPreExistingConfiguration()to be the more generic =>
- Add a new install step that installs an install profile (
install_install_profile). This is so that themes can installed before the profile so that the profile can provide configuration that depends in the theme.
ConfigInstaller::installOptionalConfig()to enable installation of optional configuration.
Original report by @catch
Found by alexpott on https://drupal.org/node/2003966#comment-7866263
- Module A provides some default configuration, to be enabled when module B is enabled.
- The default configuration references a plugin owned by module C
- Module C is not enabled when either module A or module B are
- The default configuration is installed, and is immediately broken - in Views it'd be a broken handler, some other systems can't handle it at all.
We should probably not install the configuration, if it's going to be invalid as soon as it's installed. That'd make this one a counterpart to- certainly the validation in there is going to be necessary for whatever happens here.
A couple of options then:
- skip the configuration install silently. This brings up the question of whether that configuration will ever get installed (i.e. if module C is enabled we're not going to look for configuration files in module A just in case they have a plugin owned by module C.
- prompt the person enabling the module to see if they'd also like to enable module C at the same time, then they can answer yes or know and we forget about this config file after that.
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 90,036 pass(es).
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 2090115-opt.114.patch. Unable to apply patch. See the log in the details link for more information.
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 88,635 pass(es).