diff -u b/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php --- b/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -486,6 +486,15 @@ return FALSE; } + // If the base table for the View is provided by a module being removed, we + // delete the View because this is not something that can be fixed manually. + $views_data = Views::viewsData(); + $base_table = $this->get('base_table'); + $base_table_data = $views_data->get($base_table); + if (!empty($base_table_data['table']['provider']) && in_array($base_table_data['table']['provider'], $dependencies['module'])) { + return FALSE; + } + $current_display = $this->getExecutable()->current_display; $handler_types = Views::getHandlerTypes(); @@ -532,7 +541,7 @@ // Disable the View if we made no changes or the handlers were not able to // remove the dependencies. This will cause all handler dependencies to be // ignored on dependency calculation. - // @todo Display a message or add a 'disabled' fieldset that shows any + // @todo https://www.drupal.org/node/2832558 Give better feedback for // disabled config. if ($disable) { $this->disable(); diff -u b/core/modules/views/tests/src/Kernel/ViewsConfigDependenciesIntegrationTest.php b/core/modules/views/tests/src/Kernel/ViewsConfigDependenciesIntegrationTest.php --- b/core/modules/views/tests/src/Kernel/ViewsConfigDependenciesIntegrationTest.php +++ b/core/modules/views/tests/src/Kernel/ViewsConfigDependenciesIntegrationTest.php @@ -18,7 +18,7 @@ /** * {@inheritdoc} */ - public static $modules = ['field', 'file', 'image', 'entity_test', 'user']; + public static $modules = ['field', 'file', 'image', 'entity_test', 'user', 'text']; /** * {@inheritdoc} @@ -32,6 +32,7 @@ parent::setUp($import_test_views); $this->installEntitySchema('user'); + $this->installSchema('user', ['users_data']); } /** @@ -135,2 +136,23 @@ + /** + * Tests removing a config dependency that deletes the View. + */ + public function testConfigRemovalDelete() { + // Find all the entity types provided by the entity_test module and install + // the schema for them so we can uninstall them. + $entities = \Drupal::entityTypeManager()->getDefinitions(); + foreach ($entities as $entity_type_id => $definition) { + if ($definition->getProvider() == 'entity_test') { + $this->installEntitySchema($entity_type_id); + }; + } + + // Check that removing the module that provides the base table for a View, + // deletes the View. + $this->assertNotNull(View::load('entity_test_fields')); + $this->container->get('module_installer')->uninstall(['entity_test']); + // Check that the View has been deleted. + $this->assertNull(View::load('entity_test_fields')); + } + }