diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index d340bb5..600b340 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -371,16 +371,18 @@ public static function onDependencyRemoval(FieldDefinitionInterface $field_defin if (isset($dependencies[$bundle->getConfigDependencyKey()][$bundle->getConfigDependencyName()])) { unset($handler_settings['target_bundles'][$bundle->id()]); - // If this bundle is also used in the 'auto_create_bundle' setting, make it NULL. + // If this bundle is also used in the 'auto_create_bundle' + // setting, disable the auto-creation feature completely. $auto_create_bundle = !empty($handler_settings['auto_create_bundle']) ? $handler_settings['auto_create_bundle'] : FALSE; if ($auto_create_bundle && $auto_create_bundle == $bundle->id()) { + $handler_settings['auto_create'] = NULL; $handler_settings['auto_create_bundle'] = NULL; } $bundles_changed = TRUE; // In case we deleted the only target bundle allowed by the field - // we have to log a warning message because the field will not + // we have to log a critical message because the field will not // function correctly anymore. if ($handler_settings['target_bundles'] === []) { \Drupal::logger('entity_reference')->critical('The %target_bundle bundle (entity type: %target_entity_type) was deleted. As a result, the %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', [ @@ -397,16 +399,6 @@ public static function onDependencyRemoval(FieldDefinitionInterface $field_defin } } if ($bundles_changed) { - // If there is only one possible target bundle left, use it for the - // 'auto_create_bundle' setting. - if (!empty($handler_settings['auto_create']) && count($handler_settings['target_bundles']) === 1) { - $handler_settings['auto_create_bundle'] = key($handler_settings['target_bundles']); - } - - // If there is no 'auto_create_bundle' set, disable the auto creation - // feature completely. - $handler_settings['auto_create'] = !empty($handler_settings['auto_create_bundle']); - $field_definition->setSetting('handler_settings', $handler_settings); } $changed |= $bundles_changed; diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index e1047ac..0b6105d 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -241,7 +241,7 @@ function entity_reference_entity_bundle_delete($entity_type_id, $bundle) { $field_config->save(); // In case we deleted the only target bundle allowed by the field we - // have to log a warning message because the field will not function + // have to log a critical message because the field will not function // correctly anymore. if ($handler_settings['target_bundles'] === []) { \Drupal::logger('entity_reference')->critical('The %target_bundle bundle (entity type: %target_entity_type) was deleted. As a result, the %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', [