diff --git a/core/lib/Drupal/Core/Entity/DynamicallyFieldableEntityStorageInterface.php b/core/lib/Drupal/Core/Entity/DynamicallyFieldableEntityStorageInterface.php index 9aaf35e..5037628 100644 --- a/core/lib/Drupal/Core/Entity/DynamicallyFieldableEntityStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/DynamicallyFieldableEntityStorageInterface.php @@ -23,6 +23,14 @@ interface DynamicallyFieldableEntityStorageInterface extends FieldableEntityStorageInterface, FieldStorageDefinitionListenerInterface { /** + * Determines if the storage contains any data. + * + * @return bool + * TRUE if the storage contains data, FALSE if not. + */ + public function hasData(); + + /** * Reacts to the creation of a field. * * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageInterface.php index dc35ff7..3576744 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageInterface.php @@ -19,14 +19,6 @@ interface FieldableEntityStorageInterface extends EntityStorageInterface { /** - * Determines if the storage contains any data. - * - * @return bool - * TRUE if the storage contains data, FALSE if not. - */ - public function hasData(); - - /** * Determines the number of entities with values for a given field. * * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition diff --git a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php index 927d331..fa3fecc 100644 --- a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php @@ -7,8 +7,8 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\FieldableEntityStorageInterface; use Drupal\Core\Extension\ModuleUninstallValidatorInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -16,6 +16,9 @@ /** * Validates module uninstall readiness based on defined storage definitions. + * + * @todo Remove this once we support field purging for base fields. See + * https://www.drupal.org/node/2282119. */ class FieldModuleUninstallValidator implements ModuleUninstallValidatorInterface { use StringTranslationTrait; @@ -40,12 +43,13 @@ public function validate($module_name) { $reasons = array(); foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { - // We skip entity types defined by the module as there may be no content - // for being able to uninstall them anyway. + // We skip entity types defined by the module as there must be no content + // to be able to uninstall them anyway. We also skip the Field module as + // it implements field purging. // See \Drupal\Core\Entity\ContentUninstallValidator. - if ($entity_type->getProvider() != $module_name && $entity_type instanceof ContentEntityTypeInterface) { + if ($entity_type->getProvider() != $module_name && $entity_type instanceof FieldableEntityInterface) { foreach ($this->entityManager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) { - if ($storage_definition->getProvider() == $module_name) { + if ($module_name != 'field' && $storage_definition->getProvider() == $module_name) { $storage = $this->entityManager->getStorage($entity_type_id); if ($storage instanceof FieldableEntityStorageInterface && $storage->countFieldData($storage_definition, TRUE)) { $reasons[] = $this->t('There is content for the field @field-name on entity type @entity_type.', array(