summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-05-01 00:06:44 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-05-01 00:06:44 +0000
commitfede1c118224b3fd0a91006a5dc89084086e3154 (patch)
tree714127f418ac4f495b82de6dd12d67e3228eb5ac
parentd4379fbdd945e90f63d523568f42301c2c8c7386 (diff)
downloadbrdo-fede1c118224b3fd0a91006a5dc89084086e3154.tar.gz
brdo-fede1c118224b3fd0a91006a5dc89084086e3154.tar.bz2
#777100 by jhodgdon: Fixed hook_field_storage_update_field() is not documented.
-rw-r--r--modules/field/field.api.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 1f4eca048..24b1bb169 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -453,6 +453,42 @@ function hook_field_update($entity_type, $entity, $field, $instance, $langcode,
}
/**
+ * Update the storage information for a field.
+ *
+ * This is invoked on the field's storage module from field_update_field(),
+ * before the new field information is saved to the database. The field storage
+ * module should update its storage tables to agree with the new field
+ * information. If there is a problem, the field storage module should throw an
+ * exception.
+ *
+ * @param $field
+ * The updated field structure to be saved.
+ * @param $prior_field
+ * The previously-saved field structure.
+ * @param $has_data
+ * TRUE if the field has data in storage currently.
+ */
+function hook_field_storage_update_field($field, $prior_field, $has_data) {
+ if (!$has_data) {
+ // There is no data. Re-create the tables completely.
+ $prior_schema = _field_sql_storage_schema($prior_field);
+ foreach ($prior_schema as $name => $table) {
+ db_drop_table($name, $table);
+ }
+ $schema = _field_sql_storage_schema($field);
+ foreach ($schema as $name => $table) {
+ db_create_table($name, $table);
+ }
+ }
+ else {
+ // There is data. See field_sql_storage_field_storage_update_field() for
+ // an example of what to do to modify the schema in place, preserving the
+ // old data as much as possible.
+ }
+ drupal_get_schema(NULL, TRUE);
+}
+
+/**
* Define custom delete behavior for this module's field types.
*
* This hook is invoked just before the data is deleted from field storage.