summaryrefslogtreecommitdiff
path: root/modules/field/field.crud.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-09-22 08:44:04 +0000
committerDries Buytaert <dries@buytaert.net>2009-09-22 08:44:04 +0000
commit29addd06b26192f0d3e1761e7e13b291baf7c5a1 (patch)
treebd0241978398249914c776d1f949cab6b34fed46 /modules/field/field.crud.inc
parenta4b833b6deb353d28ad51f9c648061bd0a83c950 (diff)
downloadbrdo-29addd06b26192f0d3e1761e7e13b291baf7c5a1.tar.gz
brdo-29addd06b26192f0d3e1761e7e13b291baf7c5a1.tar.bz2
- Patch #569364 by bjaspan, yched: handle failures on field storage creation.
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);