diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -8,6 +8,7 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Cache\Cache; +use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; @@ -1053,7 +1054,7 @@ // would be required before being able to uninstall them. if ($entity_type->getProvider() != $module_name && $entity_type->isFieldable()) { try { - $query = \Drupal::entityQuery($entity_type_id); + $has_data = \Drupal::entityQuery($entity_type_id)->count()->execute(); } catch (QueryException $e) { // If an entity type can't be queried, treat it has having no @@ -1061,9 +1062,19 @@ // to be uninstalled. // @todo Require all storage handlers to support querying: // https://www.drupal.org/node/2337753. - $query = NULL; + $has_data = FALSE; } - if ($query && $query->count()->execute()) { + catch (DatabaseExceptionWrapper $e) { + // During KernelTestBase tests, some entity schema are not + // installed. + if (!\Drupal::database()->schema()->tableExists($entity_type->getBaseTable())) { + $has_data = FALSE; + } + else { + throw $e; + } + } + if ($has_data) { foreach ($entity_manager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) { if ($storage_definition->getProvider() == $module_name) { $info['required'] = TRUE;