From 29addd06b26192f0d3e1761e7e13b291baf7c5a1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 22 Sep 2009 08:44:04 +0000 Subject: - Patch #569364 by bjaspan, yched: handle failures on field storage creation. --- modules/field/field.crud.inc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/field/field.crud.inc') 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); -- cgit v1.2.3