summaryrefslogtreecommitdiff
path: root/modules/field/field.crud.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field/field.crud.inc')
-rw-r--r--modules/field/field.crud.inc12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc
index d837f8aaa..7f316c4db 100644
--- a/modules/field/field.crud.inc
+++ b/modules/field/field.crud.inc
@@ -291,7 +291,17 @@ function field_create_field($field) {
// Invoke hook_field_storage_create_field after the field is
// complete (e.g. it has its id).
- module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_create_field', $field);
+ try {
+ module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_create_field', $field);
+ }
+ catch (Exception $e) {
+ // If storage creation failed, remove the field_config record before
+ // rethrowing the exception.
+ db_delete('field_config')
+ ->condition('id', $field['id'])
+ ->execute();
+ throw $e;
+ }
// Clear caches
field_cache_clear(TRUE);