A catchier issue title would be welcome ;-)
Field formatters or widgets are grouped together by EntityFormDisplay::getPluginCollections()
and EntityViewDisplay::getPluginCollections()
before calculating their dependencies for the display mode config entity's complete dependencies. I guess this is because there's usually no need to check the dependencies of a formatter/widget more than once, but it's common for multiple fields to use the same formatter/widgets. However, some formatters/widgets may have a different set of dependencies if they have different settings - but only one instance will be checked. I hit this issue with an entity browser widget, which is dependent on the configured entity browser. But I believe the comment formatter (CommentDefaultFormatter) is an example in core that could have this issue too, as its calculateDependencies()
method will add a dependency on the view mode that the formatter is set to use. So, this would probably replicate the issue:
1. Enable comment module.
2. Add a custom view mode for comment entities.
3. Set up two comment fields on a node type.
4. Configure both fields to display in a view mode of the node type, but set each one to show the Comments in a different view mode: one to use the custom one from step 2, and the other to use the default 'Full comment' view mode.
5. Export configuration, or inspect the node type's view mode, and you should find that it is dependent on only one of the comment view modes, rather than both.
That problem in step 5 there could result in configuration being incorrectly synchronised, because a dependency would be missed.
I suspect the solution could either be:
A. Key the $configurations
variable in EntityFormDisplay::getPluginCollections()
and EntityViewDisplay::getPluginCollections()
by something more unique than the formatter/widget ID, e.g. the ID concatenated with a serialised array of its settings?
B. Add a method that widgets & formatters could implement to return the parts that should be concatenated to the ID for keying by? (So that the majority of them can keep existing behaviour, avoiding calculating dependencies again and again for all the simpler formatters & widgets).
C. Calculate dependencies for each field/component, even if that is unnecessary for most formatters & widgets. i.e. rather than doing it for each plugin.
I hope that makes sense -- sorry I don't have much time to write a test to show this issue or a patch to demonstrate a solution!