diff -u b/core/core.services.yml b/core/core.services.yml --- b/core/core.services.yml +++ b/core/core.services.yml @@ -291,7 +291,7 @@ arguments: ['@app.root', '%container.modules%', '@cache.bootstrap'] module_installer: class: Drupal\Core\Extension\ModuleInstaller - arguments: ['@app.root', '@module_handler', '@kernel', '@entity.manager'] + arguments: ['@app.root', '@module_handler', '@kernel', '@entity.manager', '@entity.query'] theme_handler: class: Drupal\Core\Extension\ThemeHandler arguments: ['@app.root', '@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder_indicator'] diff -u b/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php --- b/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -11,6 +11,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\DrupalKernelInterface; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\Query\QueryFactoryInterface; /** * Default implementation of the module installer. @@ -42,11 +43,17 @@ protected $root; /** + * The entity manager. * @var \Drupal\Core\Entity\EntityManagerInterface */ protected $entityManager; /** + * The entity query factory. + * @var \Drupal\Core\Entity\Query\QueryFactoryInterface + */ + + /** * Modules that can be uninstalled. * @var array */ @@ -63,15 +70,18 @@ * The drupal kernel. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\Query\QueryFactoryInterface $entity_query + * The entity query factory. * * @see \Drupal\Core\DrupalKernel * @see \Drupal\Core\CoreServiceProvider */ - public function __construct($root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, EntityManagerInterface $entity_manager) { + public function __construct($root, ModuleHandlerInterface $module_handler, DrupalKernelInterface $kernel, EntityManagerInterface $entity_manager, QueryFactoryInterface $entity_query) { $this->root = $root; $this->moduleHandler = $module_handler; $this->kernel = $kernel; $this->entityManager = $entity_manager; + $this->entityQueryFactory = $entity_query; } /** @@ -479,7 +489,7 @@ /** * {@inheritdoc} */ - public function validateUninstall($module_list) { + public function validateUninstall(array $module_list) { foreach ($module_list as $module) { if (isset($this->uninstallValidated[$module])) { continue; @@ -488,7 +498,7 @@ unset($module_list[$module]); } else { - $this->uninstallValidated = $module; + $this->uninstallValidated[] = $module; } } return $module_list; @@ -505,10 +515,10 @@ */ protected function moduleHasContent($module) { $entities = $this->entityManager->getDefinitions(); - $factory = \Drupal::service('entity.query'); + $query_factory = \Drupal::service('entity.query'); foreach ($entities as $entity_type) { if ($module == $entity_type->getProvider() && is_subclass_of($entity_type->getClass(), 'Drupal\Core\Entity\Sql\SqlContentEntityStorage')) { - $content = $factory->get($entity_type->id()) + $content = $query_factory->get($entity_type->id()) ->accessCheck(FALSE) ->range(0, 1) ->execute(); diff -u b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php --- b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstallerInterface.php @@ -64,7 +64,7 @@ * @param array $module_list * The modules to uninstall. */ - public function validateUninstall($module_list); + public function validateUninstall(array $module_list); }