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']);
          }

Comments

mpotter created an issue. See original summary.

mpotter’s picture

Looks 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.

mpotter’s picture

Status: Active » Needs review
StatusFileSize
new5.1 KB

OK, here is a patch to fix this issue. Probably needs a test.

Status: Needs review » Needs work

The last submitted patch, 3: features_config_dependencies-2687245-3.patch, failed testing.

nedjo’s picture

Could we instead simply call FeaturesManager:assignConfigPackage() from FeaturesEditForm::submitForm()? Is there a reason we're not doing so?

mpotter’s picture

I 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.

mpotter’s picture

So maybe something more like this patch.

mpotter’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: features_config_dependencies-2687245-7.patch, failed testing.

mpotter’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: features_config_dependencies-2687245-7.patch, failed testing.

mpotter’s picture

Status: Needs work » Needs review
StatusFileSize
new5.9 KB

OK, the tests were failing because of trying to get dependency of simple config. Added a check for that, so this patch should pass tests.

  • mpotter committed f8b0b7f on 8.x-3.x
    Issue #2687245 by mpotter: Config dependencies not getting added to...
mpotter’s picture

Status: Needs review » Fixed

Tests pass! Committed to f8b0b7f.

Status: Fixed » Closed (fixed)

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