- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Related, with 162 followers: π¬ Drupal 10 updating issue - Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist Needs work .
- First commit to issue fork.
- Merge request !13171Issue #2579743: Make it possible for plugins in a config entity plugin... β (Open) created by godotislate
Created MR 13171 with a new approach that is mostly based on the MR for π Deleting a Media view mode should not result in the deletion of an entire text format Active , combined with some ideas from the patch in #70:
- Add new interface
Drupal\Core\Plugin\RemovableDependentPluginInterface
with methodonCollectionDependencyRemoval()
- Add code in
ConfigEntityBase::onDependencyRemoval()
that tests if the entity implementsEntityWithPluginCollectionInterface
. If so, iterate through collections and if there are plugin that implementRemovableDependentPluginInterfacedependencies::onCollectionDependencyRemoval()
, invoke the method on that plugin so it can react by changing its configuration or removing itself from the collection - If
onCollectionDependencyRemoval()
returns TRUE, thenConfigEntityBase::onDependencyRemoval()
will return TRUE, so the config entity's dependencies can be recalculated - Implement two use cases: 1) prevent image styles from being deleted if a module that provides any of its image effects is uninstalled and 2) prevent filter formats from being deleted if a media entity view mode used in a media embed filter is deleted
- Add kernel tests for two use cases
This approach kind of comes at the problem from the other way of the patch. The handling of the dependency removal is done completely in the plugin class, other than the entity invoking the plugin's onCollectionDependencyRemoval() method. The plugin collection and index ID of the plugin instance in the collection are provided as arguments along with the dependencies, so that the plugin instance can be removed from the collection as needed. This approach is kind of based on how
Drupal\views\Entity\View\onDependencyRemoval() invokes
DependentWithRemovalPluginInterface::onDependencyRemoval()
for handler plugins, as well asFieldItemInterface::onDependencyRemoval(),
which has the field definition object as well as the dependencies passed in.There may need to be tests added to test the dependency removal handling generically. The tests in the MR are kernel tests specific to the the image style and media view mode use cases. The unit tests in #70 no longer apply to the solution.
Also bumping this to critical, because π Deleting a Media view mode should not result in the deletion of an entire text format Active combined with π Deleting filter formats may result in data loss Active can lead to content data loss. There is a case of this actually happening brought up in slack: https://drupal.slack.com/archives/C1BB308HH/p1755719629686569
Also, with this π Deleting a Media view mode should not result in the deletion of an entire text format Active is effectively a duplicate, so it perhaps can be closed with credits transferred here.
- Add new interface
Changed the functional test for media to a kernel test, and added a unit test for more generic coverage.