diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index d0d5da9..be41854 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -276,6 +276,17 @@ function hook_field_schema($field) { } /** + * Allows modules to alter the schema for a field. + * + * @param $schema + * The schema definition as returned by hook_field_schema(). + * @param $field + * The field definition. + */ +function hook_schema_alter(&$schema, $field) { +} + +/** * Define custom load behavior for this module's field types. * * Unlike most other field hooks, this hook operates on multiple entities. The diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index e34c0c5..bdd329e 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -129,6 +129,7 @@ function field_create_field($field) { module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array()); + drupal_alter('field_schema', $schema, $field); // 'columns' are hardcoded in the field type. $field['columns'] = $schema['columns']; // 'foreign keys' are hardcoded in the field type. @@ -241,6 +242,7 @@ function field_update_field($field) { module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array()); + drupal_alter('field_schema', $schema, $field); // 'columns' are hardcoded in the field type. $field['columns'] = $schema['columns']; // 'indexes' can be both hardcoded in the field type, and specified in the @@ -368,6 +370,7 @@ function field_read_fields($params = array(), $include_additional = array()) { module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); $schema += array('columns' => array(), 'indexes' => array()); + drupal_alter('field_schema', $schema, $field); $field['columns'] = $schema['columns']; $field_name = $field['field_name'];