X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Fsrc%2FEntity%2FFieldStorageConfig.php;h=6ae439ec5a4c321eb2b4009b39ad1ce852fdbb8d;hb=74df008bdbb3a11eeea356744f39b802369bda3c;hp=bf2641ed4e680f65efcc56054442c4311ada7730;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/field/src/Entity/FieldStorageConfig.php b/web/core/modules/field/src/Entity/FieldStorageConfig.php index bf2641ed4..6ae439ec5 100644 --- a/web/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/web/core/modules/field/src/Entity/FieldStorageConfig.php @@ -398,7 +398,8 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $field_storages) { - $state = \Drupal::state(); + /** @var \Drupal\Core\Field\DeletedFieldsRepositoryInterface $deleted_fields_repository */ + $deleted_fields_repository = \Drupal::service('entity_field.deleted_fields_repository'); // Set the static flag so that we don't delete field storages whilst // deleting fields. @@ -407,23 +408,19 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI // Delete or fix any configuration that is dependent, for example, fields. parent::preDelete($storage, $field_storages); - // Keep the field definitions in the state storage so we can use them later - // during field_purge_batch(). - $deleted_storages = $state->get('field.storage.deleted') ?: []; + // Keep the field storage definitions in the deleted fields repository so we + // can use them later during field_purge_batch(). /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ foreach ($field_storages as $field_storage) { // Only mark a field for purging if there is data. Otherwise, just remove // it. $target_entity_storage = \Drupal::entityTypeManager()->getStorage($field_storage->getTargetEntityTypeId()); if (!$field_storage->deleted && $target_entity_storage instanceof FieldableEntityStorageInterface && $target_entity_storage->countFieldData($field_storage, TRUE)) { - $config = $field_storage->toArray(); - $config['deleted'] = TRUE; - $config['bundles'] = $field_storage->getBundles(); - $deleted_storages[$field_storage->uuid()] = $config; + $storage_definition = clone $field_storage; + $storage_definition->deleted = TRUE; + $deleted_fields_repository->addFieldStorageDefinition($storage_definition); } } - - $state->set('field.storage.deleted', $deleted_storages); } /**