diff -u b/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php --- b/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -721,6 +721,13 @@ // Allow modules to react prior to the uninstallation of a module. $this->invokeAll('module_preuninstall', array($module)); + // Remove all dependent configuration entities. + $dependent_entities = $this->findConfigEntityDependents(array($module)); + foreach ($dependent_entities as $entity_type_id => $entities) { + $controller = \Drupal::entityManager()->getStorageController($entity_type_id); + $controller->delete($entities); + } + // Uninstall the module. module_load_install($module); $this->invoke($module, 'uninstall'); @@ -729,12 +736,6 @@ // Remove the module's entry from the config. $module_config->clear("enabled.$module")->save(); - // Remove all dependent configuration entities. - $dependent_entities = $this->findConfigEntityDependents(array($module)); - foreach ($dependent_entities as $entity_type_id => $entities) { - $controller = \Drupal::entityManager()->getStorageController($entity_type_id); - $controller->delete($entities); - } // Remove all configuration belonging to the module. \Drupal::service('config.manager')->uninstall('module', $module); only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -131,6 +131,8 @@ public function installDefaultConfig($type, $name) { } $this->configFactory->setOverrideState($old_state); } + // Reset all the static caches and list caches. + $this->configFactory->reset(); } } only in patch2: unchanged: --- a/core/modules/language/lib/Drupal/language/Entity/Language.php +++ b/core/modules/language/lib/Drupal/language/Entity/Language.php @@ -105,11 +105,35 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { * @throws \RuntimeException */ public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) { - $default_language = \Drupal::service('language.default')->get(); + $default_language = static::getDefaultLanguage(); foreach ($entities as $entity) { if ($entity->id() == $default_language->id) { throw new DeleteDefaultLanguageException('Can not delete the default language'); } } } + + /** + * {@inheritdoc} + */ + public function hasDependency($type, $name) { + // Default languages can not be removed so do not allow them to be dependent + // on anything. This gets around the fact that uninstalling language would + // attempt to delete the default language which would cause the exception in + // \Drupal\language\Entity\Language::preDelete() to be thrown. + if ($this->id() == $this->getDefaultLanguage()->id) { + return FALSE; + } + return parent::hasDependency($type, $name); + } + + /** + * Gets the default language. + * + * @return \Drupal\Core\Language\Language + */ + protected static function getDefaultLanguage() { + return \Drupal::service('language.default')->get(); + } + } only in patch2: unchanged: --- a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php @@ -151,6 +151,7 @@ public function customErrorHandler($error_level, $message, $filename, $line, $co */ public function testLoadFunctions() { $this->enableModules(array('node')); + $this->installConfig(array('node')); $controller = $this->container->get('entity.manager')->getStorageController('view'); // Test views_view_is_enabled/disabled.