Problem/Motivation
Use hook_ entity_ base_ field_ Info () adds entity reference fields for user entities, which cannot be uninstalled after cancellation.
Steps to reproduce
1、Add Entity Reference Field:
function test_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type->id() === 'user') {
$fields['test'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the Apps content entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
}
return $fields;
}
2、Delete the field hook added in the previous step, and unload the entity entity reference field
3、Error message:
The form display and display are deleted normally, but the entity reference field in the users_field_data table fails to be deleted
\Drupal::entityDefinitionUpdateManager()->uninstallFieldStorageDefinition($field_storage_definition),Same question.