summaryrefslogtreecommitdiff
path: root/modules/field/field.crud.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-11 03:42:34 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-09-11 03:42:34 +0000
commit3da4e0e0157b62d4aacd8857bd1f09c079718a05 (patch)
tree48ee50ed2dac4b49479dbe9d531fe021900f97f0 /modules/field/field.crud.inc
parent9b3c7eb44f6f0aa647a63380c2be8cd3a97f2571 (diff)
downloadbrdo-3da4e0e0157b62d4aacd8857bd1f09c079718a05.tar.gz
brdo-3da4e0e0157b62d4aacd8857bd1f09c079718a05.tar.bz2
#382464 by fgm and bjaspan: Disallow reserved field names.
Diffstat (limited to 'modules/field/field.crud.inc')
-rw-r--r--modules/field/field.crud.inc9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc
index 8e0ff1497..d837f8aaa 100644
--- a/modules/field/field.crud.inc
+++ b/modules/field/field.crud.inc
@@ -239,6 +239,15 @@ function field_create_field($field) {
throw new FieldException($message);
}
+ // Disallow reserved field names. This can't prevent all field name
+ // collisions with existing object properties, but some is better
+ // than none.
+ foreach (field_info_fieldable_types() as $type => $info) {
+ if (in_array($field['field_name'], $info['object keys'])) {
+ throw new FieldException(t('Attempt to create field name %name which is reserved by entity type %type.', array('%name' => $field['field_name'], '%type' => $type)));
+ }
+ }
+
$field += array(
'cardinality' => 1,
'translatable' => FALSE,