Exporting config to a Feature doesn't add the dependencies of the config to the feature itself.
For example, a taxonomy reference field_storage has a dependency on the "taxonomy" module. The "taxonomy" module is not providing any config, but is a dependency. If I generate a Feature Module A that contains this field_storage, it's important to add "taxonomy" as a dependency to this feature module. Otherwise during a site install Drupal can attempt to enable my Feature Module A *before* Taxonomy is enabled, causing UnMetDependencies errors.
edit report as spam
To test this:
1) Create new feature
2) Add a field_storage for a field that has a module dependency
3) Generate the feature
the features.info.yml doesn't have any dependency in it.
Seems like the dependencies are set in the FeatureManager::assignConfigPackage() function. But this function isn't called when adding new items to a new feature?
From nedjo:
As you note, it's supposed to be handled by these lines in FeaturesManager:assignConfigPackage():
// For configuration in the InstallStorage::CONFIG_INSTALL_DIRECTORY
// directory, set any module dependencies of the configuration item
// as package dependencies.
// As its name implies, the core-provided
// InstallStorage::CONFIG_OPTIONAL_DIRECTORY should not create
// dependencies.
if ($config_collection[$item_name]->getSubdirectory() === InstallStorage::CONFIG_INSTALL_DIRECTORY && isset($config_collection[$item_name]->getData()['dependencies']['module'])) {
$module_dependencies = array_merge($module_dependencies, $config_collection[$item_name]->getData()['dependencies']['module']);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | features_config_dependencies-2687245-12.patch | 5.9 KB | mpotter |
| #7 | features_config_dependencies-2687245-7.patch | 5.78 KB | mpotter |
| #3 | features_config_dependencies-2687245-3.patch | 5.1 KB | mpotter |
Comments
Comment #2
mpotter commentedLooks like the above lines handle computing the dependencies for when config is assigned to packages. But this isn't called when creating a New feature before it is exported. Looking into it.
Comment #3
mpotter commentedOK, here is a patch to fix this issue. Probably needs a test.
Comment #5
nedjoCould we instead simply call
FeaturesManager:assignConfigPackage()fromFeaturesEditForm::submitForm()? Is there a reason we're not doing so?Comment #6
mpotter commentedI thought about that. Maybe I'll add it there also. But I think it's still a good idea to have it "fix" dependencies before creating the *.info file in case something gets added elsewhere.
Comment #7
mpotter commentedSo maybe something more like this patch.
Comment #8
mpotter commentedComment #10
mpotter commentedComment #12
mpotter commentedOK, the tests were failing because of trying to get dependency of simple config. Added a check for that, so this patch should pass tests.
Comment #14
mpotter commentedTests pass! Committed to f8b0b7f.