From 3da4e0e0157b62d4aacd8857bd1f09c079718a05 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 11 Sep 2009 03:42:34 +0000 Subject: #382464 by fgm and bjaspan: Disallow reserved field names. --- modules/field/field.crud.inc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/field/field.crud.inc') 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, -- cgit v1.2.3