diff --git a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaManager.php b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaManager.php index b72f2f3..2db8285 100644 --- a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaManager.php +++ b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaManager.php @@ -238,7 +238,7 @@ public function applyChanges($entity_type_id = NULL) { break; case static::DEFINITION_DELETED: - $this->onFieldStorageDefinitionDelete($storage_definitions[$field_name]); + $this->onFieldStorageDefinitionDelete($original_storage_definitions[$field_name]); break; } } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index f3b65a2..1085297 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -5,20 +5,20 @@ * Configuration system that lets administrators modify the workings of the site. */ +use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Cache\Cache; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; -use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Menu\MenuTreeParameters; +use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\StringTranslation\TranslationWrapper; use Drupal\Core\Url; -use Drupal\Core\Block\BlockPluginInterface; use Drupal\user\UserInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; use GuzzleHttp\Exception\RequestException; +use Symfony\Component\HttpFoundation\RedirectResponse; /** * New users will be set to the default time zone at registration. @@ -1032,11 +1032,39 @@ function system_sort_themes($a, $b) { * Implements hook_system_info_alter(). */ function system_system_info_alter(&$info, Extension $file, $type) { - // Remove page-top and page-bottom from the blocks UI since they are reserved for - // modules to populate from outside the blocks system. - if ($type == 'theme') { - $info['regions_hidden'][] = 'page_top'; - $info['regions_hidden'][] = 'page_bottom'; + switch ($type) { + case 'theme': + // Remove page-top and page-bottom from the blocks UI since they are + // reserved for modules to populate from outside the blocks system. + $info['regions_hidden'][] = 'page_top'; + $info['regions_hidden'][] = 'page_bottom'; + break; + + case 'module': + // @todo Unify this with field_system_info_alter() once purging is + // supported for any field. See https://www.drupal.org/node/2282119. + $module_name = $file->getName(); + if ($module_name != 'field') { + $entity_manager = \Drupal::entityManager(); + foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { + if ($entity_type instanceof ContentEntityTypeInterface && $entity_manager->getStorage($entity_type_id)->hasData()) { + try { + foreach ($entity_manager->getFieldStorageDefinitions($entity_type_id) as $definition) { + if ($definition->getProvider() == $module_name) { + $info['required'] = TRUE; + $info['explanation'] = t('Fields type(s) in use'); + break; + } + } + } + catch (\LogicException $e) { + // If the entity type does not support retrieving base fields we + // have nothing to do here. + } + } + } + } + break; } }