#2080823: Create API to discover config entities' soft dependencies and use this to present a confirm form on module uninstall added a method getDependentEntities() to \Drupal\Core\Config\Entity\ConfigDependencyManager. The documentation for this method simply says that it "gets dependencies". The implication is that it returns the list of forward dependencies for a given configuration entity. For instance, if I pass it a field instance config, I would expect it to return just the storage config as a dependency. If I pass the field storage config, I would expect it to usually return nothing.
However, the actual behavior seems to be to return the entire dependency tree, including reverse dependencies. In other words, if I pass it a field storage config, I get the field instance config and everything that depends on that config (for instance, views) all the way back up the dependency tree. This is because the method in turn calls createGraphConfigEntityDependencies(), which returns the reverse paths for the dependency graph.
This is problematic because Features relies on this method to return the dependencies for a given config (#2533844: Use ConfigDependencyManager for determining config dependency), but since it's actually returning dependencies and dependent configs, dependencies are erroneously included, causing #2720167: Config dependency detection logic.
At the least, the documentation for this method needs to be updated to clarify the intended behavior. If the method is behaving as intended, then Features is probably using it incorrectly and needs to find a new method of building dependencies trees. If the method is not behaving as intended, then it needs to be patched.
Comment | File | Size | Author |
---|---|---|---|
#31 | 2724835-31.patch | 2.08 KB | benjifisher |
#31 | diff-2724835-18-31.txt | 651 bytes | benjifisher |
#18 | interdiff.txt | 764 bytes | mparker17 |
#18 | ConfigDependencyManager-documentation-2724835-18.patch | 2.4 KB | mparker17 |
Comments
Comment #2
Dane Powell CreditAttribution: Dane Powell at Acquia commentedComment #3
Dane Powell CreditAttribution: Dane Powell at Acquia commentedComment #4
Wim LeersComment #5
Wim LeersWe see:
This is indeed very confusing at best.
Furthermore:
\Drupal\Core\Config\Entity\ConfigDependencyManager
does not even mention this public API methodComment #6
Salif CreditAttribution: Salif as a volunteer commentedI'm working on this in Drupal North code sprint
Comment #7
Salif CreditAttribution: Salif as a volunteer commentedThank you to check my first patch
Comment #8
Dane Powell CreditAttribution: Dane Powell at Acquia commentedThis patch satisfies my curiosity. I'm not entirely familiar with the intended behavior of the function, but it seems to describe the actual behavior well enough.
Comment #9
Wim LeersAssigning to @alexpott since he's both a committer and maintainer of this subsystem, so he's best able to review this.
(There are whitespace problems in this patch, but that's less important for now — what matters most is whether the content is accurate.)
Comment #10
alexpottIt doesn't return the graph anymore. It returns a list of ConfigEntityDependency objects in the order of the nearest to the thing you passed in. So if you pass in Node module you get node_type -> field_storage -> field -> entity view displays.
This is too much about implementation and not what is being calculated. See the issue summary of #2754477: Unexpected config entity delete due to dependency calculations which has some pictures that explain what is going on here.
Lines have spaces.
We should probably add an @see to \Drupal\Core\Entity\EntityInterface::getConfigDependencyName()
I'm not sure this is better.
Comment #11
Salif CreditAttribution: Salif as a volunteer commentedAs per @Alexpott review in comment #10
An Interdiff for patch 2724835-ConfigDependencyManager-documentation-7
Comment #12
Salif CreditAttribution: Salif as a volunteer commentedSorry about #11 without files.
As per @Alexpott review in comment #10
An Interdiff-2724835-ConfigDependencyManager-documentation-7-12
Comment #13
mparker17The patch in #12 seems to address all of @alexpott's comments; and contains no whitespace errors. +1 to RTBC.
Comment #14
alexpottI'm not sure about this formatting. Also, if we use an ellipsis we should use the proper unicode character.
I don't think this change is necessary. We could add documentation to the return to say if nothing is dependent it'll be empty.
Comment #15
deepakaryan1988Comment #16
deepakaryan1988Address the points in #14
Comment #17
Mile23Way more helpful than the current docs. :-)
Patch applies to 8.1.x, 8.2.x, 8.3.x.
'Returns an empty array If there are no ancestors.'
Comment #18
mparker17Sounds good.
Comment #20
Mile23Pretty sure the 8.1.x fail is unrelated, since this is a documentation change.
Looks good, thanks.
Comment #21
xjmIsn't this hardcoding documentation of something that can change? I think we need to add a bit more context, or a simpler, made-up example.
AFAIK we still have content dependencies, so why is that word being removed?
Comment #25
ashishdalviMarking issue for Drupal Mumbai Code Sprint
Comment #30
benjifisherHere is a reroll of the patch in #18. As the diff (not interdiff) shows, the only difference is a line of context. The patch in #18 was made before we switched to short array syntax.
I am removing the "rc eleigible" issue tag. I think it is out of date. I am also removing DrupalMumbaiCodeSprint, since it looks as though this issue was not touched at that event.
Comment #31
benjifisherOops, I forgot to revert the change I made in order to apply the patch from #18. Ignore the patch, diff attached to #30: new ones attached now.