diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 9334a88..2e9e44d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -7,6 +7,8 @@ use Drupal\Component\Utility\UrlHelper; 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; use Drupal\Core\Form\FormState; @@ -1045,6 +1047,27 @@ function system_system_info_alter(&$info, Extension $file, $type) { $info['regions_hidden'][] = 'page_top'; $info['regions_hidden'][] = 'page_bottom'; } + + if ($type == 'module' && empty($info['required'])) { + foreach (\Drupal::entityManager()->getDefinitions() as $entity_type) { + try { + if ($file->getName() == $entity_type->getProvider() && + is_subclass_of($entity_type->getClass(), '\Drupal\Core\Entity\ContentEntityInterface') && + \Drupal::entityQuery($entity_type->id())->accessCheck(FALSE)->count()->execute() + ) { + $info['required'] = TRUE; + $info['explanation'] = t('Content in use'); + } + } + // @todo Remove once https://www.drupal.org/node/2337753 is fixed. + catch (QueryException $e) { + } + // @todo Some KernelTestBase tests install entity types without their + // schema. Figure out what to do about that and then remove this. + catch (DatabaseExceptionWrapper $e) { + } + } + } } /**