diff -u b/core/modules/filter/src/Entity/FilterFormat.php b/core/modules/filter/src/Entity/FilterFormat.php --- b/core/modules/filter/src/Entity/FilterFormat.php +++ b/core/modules/filter/src/Entity/FilterFormat.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Entity; +use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityWithPluginCollectionInterface; use Drupal\Core\Entity\EntityStorageInterface; @@ -414,2 +415,15 @@ + /** + * {@inheritdoc} + */ + protected function calculatePluginDependencies(PluginInspectionInterface $instance) { + // Only add dependencies for plugins that are actually configured. This is + // necessary because the filter plugin collection will return all available + // filter plugins. + // @see \Drupal\filter\FilterPluginCollection::getConfiguration() + if (isset($this->filters[$instance->getPluginId()])) { + parent::calculatePluginDependencies($instance); + } + } + } diff -u b/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php --- b/core/modules/filter/src/Tests/FilterAPITest.php +++ b/core/modules/filter/src/Tests/FilterAPITest.php @@ -395,14 +395,18 @@ */ public function testDependencyRemoval() { - $filter_format = entity_load('filter_format', 'filtered_html'); - $filter_config = array( + $this->installSchema('user', array('users_data')); + $filter_format = \Drupal\filter\Entity\FilterFormat::load('filtered_html'); + $filter_config = [ 'weight' => 10, 'status' => 1, - ); + ]; $filter_format->setFilterConfig('filter_test_restrict_tags_and_attributes', $filter_config); $filter_format->save(); - $this->uninstallModule('filter_test'); - $filter_format = entity_load('filter_format', 'filtered_html'); - $this->assertEqual('Drupal\filter\Entity\FilterFormat', get_class($filter_format)); + $this->assertEqual(['module' => ['filter_test']], $filter_format->getDependencies()); + \Drupal::moduleHandler()->uninstall(array('filter_test')); + + \Drupal::entityManager()->getStorage('filter_format')->resetCache(); + $filter_format = \Drupal\filter\Entity\FilterFormat::load('filtered_html'); + $this->assertEqual([], $filter_format->getDependencies()); } }