Problem/Motivation
Currently we analyze the extension dependencies of configuration assigned to a package and add package dependencies on those extensions.
However - for default config in the config/install directory, at least - there is a dependency on the module that provides the configuration entity type, which typically is not included in the declared dependencies of a given configuration type.
For example, a contact form might be exported as follows:
langcode: en
status: true
dependencies: { }
id: feedback
label: 'Website feedback'
recipients:
- admin@example.com
reply: ''
weight: 0The feature to which this item is assigned won't get a dependency on the contact module, and will generate an install error when installed (unless the contact module is already installed).
Proposed resolution
Where config of given types are assigned to a package, add dependencies on modules that provide the configuration types.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 2653046-17.patch | 1.96 KB | mpotter |
| #8 | 2653046-8.patch | 2.08 KB | nedjo |
Comments
Comment #2
nedjoComment #3
dawehner, so a humble +1 here.
Comment #4
nedjoUpdating per discussion with dawehner.
Comment #5
nedjoEscalating to major since generated features can't be installed.
Approach in attached patch: when assigning a configuration item to a package, determine the provider of the item's configuration type and, if the provider is an installed module (and not, for example, 'core'), add it as a dependency.
Comment #6
nedjoThis patch adds testing, not yet for this issue, but for the existing dependency handling (add dependency on module that the config item depends on).
Comment #8
nedjoI went ahead and committed this because it's the last blocker to a much-needed alpha release.
Attached patch is a draft of a test. So far it's failing. In
FeaturesManager::assignConfigPackage()this lineis evaluating to
FALSEwhen it should beTRUE. I'm attempting to get the test to return['my_module' => NULL]for$module_list, see this part of the patch:Help appreciated!
Comment #10
mpotter commentedNot sure this is actually working. I exported some field_storage to a new feature and none of the module dependencies from the config were added to the feature itself. Will look into this a bit more.
Comment #11
mpotter commentedFrom #3:
No, I disagree with this. If Features is creating a module containing config, the dependencies from the config need to be added to the module. If the module developer wants to remove this for some reason they can. But many people using Features to organize their config are not module developers and just want to be able to enable the module they just created.
Trying to use Features in a new D8 distro that we are building for a client, this lack of dependency info became a huge issue and a lot of manual work.
So, what was the rationale for saying that Features should *not* add the dependencies to the exported module?
Comment #12
mpotter commentedSo, I think maybe this issue is talking about something different. The code in patch #5 is trying to add a dependency of a module that contains dependent config. And it's possible this is working.
But what isn't working is when the config item itself contains dependencies. 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.
Comment #13
mpotter commentedTo 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?
Comment #14
nedjo@mpotter: yes, let's get a new issue filed for this, since it's a separate problem.
As you note, it's supposed to be handled by these lines in
FeaturesManager:assignConfigPackage():Comment #15
mpotter commentedOK, moved to #2687245: Config dependencies not getting added to Feature export.
Leaving this issue open to review the work needed to get the patch working as reported as failing in #9
Comment #16
mpotter commentedThe "Major" issue was committed in #7 and this issue just remains for getting the test working.
Comment #17
mpotter commentedHere is a patch with a fixed test. We needed to change the return expectation of getModuleList so the isset() would be true.
Comment #19
mpotter commentedCommitted to 81679b1.