EntityFormDisplay::getPluginCollections()
and EntityViewDisplay::getPluginCollections()
enable widget/formatter plugin dependencies to be added to the dependency list of the form/view display. This is supposed to prevent a deleted field dependency from breaking the display. The issue is that plugin collection is keyed by the type of the plugin. Here is the code for the view display, the form display code is nearly identical:
$configurations[$configuration['type']] = $configuration + [
'field_definition' => $field_definition,
'view_mode' => $this->originalMode,
];
Multiple instances of a widget/formatter plugin will all have the same type, which means that if you have more than one instance on a display then the configuration for later instances will overwrite that of earlier instances. Only the configuration of the last instance will be added to the collections array. Therefore, only the dependencies of the last instance will be registered with the display. If a missing dependency is then deleted, the form/view display page will be broken due to a missing dependency exception.
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.
Entity browsers may be the most common other example, as media formatters depend on them.
The patch in #9 keys the plugin collection array by the field name to ensure the key is unique in a display. According to the review in #12, re-keying the array should not have an impact on other code. The calculateDependencies() method that aggregates these dependencies does not use the keys at all.
Add update hook and tests.
None.
None.
None.
Needs work
10.1 β¨
It is used to alert the maintainer(s) of a particular core subsystem that an issue significantly impacts their subsystem, and their signoff is needed (see the governance policy draft for more information). Also, if you use this tag, make sure the issue component is set to the correct subsystem. If an issue significantly impacts more than one subsystem, use needs framework manager review instead.
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.