summaryrefslogtreecommitdiff
path: root/modules/field/field.install
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-12-18 02:04:36 +0000
committerDries Buytaert <dries@buytaert.net>2010-12-18 02:04:36 +0000
commit51118f3fb45149894213f5eae9554d1291c5f30d (patch)
tree335426488682b200b2e5524395a5e6cc751def7f /modules/field/field.install
parentd12eba1705dfa3c6f7da93f81c403b33de8fd8fc (diff)
downloadbrdo-51118f3fb45149894213f5eae9554d1291c5f30d.tar.gz
brdo-51118f3fb45149894213f5eae9554d1291c5f30d.tar.bz2
- Patch #996160 by yched, chx: issues with Fields created during 6 to 7 upgrade.
Diffstat (limited to 'modules/field/field.install')
-rw-r--r--modules/field/field.install54
1 files changed, 43 insertions, 11 deletions
diff --git a/modules/field/field.install b/modules/field/field.install
index a95f4c639..6bb0f35ab 100644
--- a/modules/field/field.install
+++ b/modules/field/field.install
@@ -197,6 +197,17 @@ function _update_7000_field_create_field(&$field) {
'active' => 1,
);
+ // Fetch the field schema to initialize columns and indexes. The field module
+ // is not guaranteed to be loaded at this point.
+ module_load_install($field['module']);
+ $schema = (array) module_invoke($field['module'], 'field_schema', $field);
+ $schema += array('columns' => array(), 'indexes' => array());
+ // 'columns' are hardcoded in the field type.
+ $field['columns'] = $schema['columns'];
+ // 'indexes' can be both hardcoded in the field type, and specified in the
+ // incoming $field definition.
+ $field['indexes'] += $schema['indexes'];
+
// The serialized 'data' column contains everything from $field that does not
// have its own column and is not automatically populated when the field is
// read.
@@ -226,17 +237,7 @@ function _update_7000_field_create_field(&$field) {
->fields($record)
->execute();
- // Create storage for this field, the field module is not guaranteed to be
- // loaded at this point.
- module_load_install($field['module']);
- $schema = (array) module_invoke($field['module'], 'field_schema', $field);
- $schema += array('columns' => array(), 'indexes' => array());
- // 'columns' are hardcoded in the field type.
- $field['columns'] = $schema['columns'];
- // 'indexes' can be both hardcoded in the field type, and specified in the
- // incoming $field definition.
- $field['indexes'] += $schema['indexes'];
-
+ // Create storage for the field.
field_sql_storage_field_storage_create_field($field);
}
@@ -395,5 +396,36 @@ function field_update_7000() {
}
/**
+ * Fix fields definitions created during the d6 to d7 upgarde path.
+ */
+function field_update_7001() {
+ $fields = _update_7000_field_read_fields();
+ foreach ($fields as $field) {
+ // _update_7000_field_create_field() was broken in d7 RC2, and the fields
+ // created during a d6 to d7 upgrade do not correcly store the 'index'
+ // entry. See http://drupal.org/node/996160.
+
+ module_load_install($field['module']);
+ $schema = (array) module_invoke($field['module'], 'field_schema', $field);
+ $schema += array('indexes' => array());
+ // 'indexes' can be both hardcoded in the field type, and specified in the
+ // incoming $field definition.
+ $field['indexes'] += $schema['indexes'];
+
+ // Place the updated entries in the existing serialized 'data' column.
+ $data = db_query("SELECT data FROM {field_config} WHERE id = :id", array(':id' => $field['id']))->fetchField();
+ $data = unserialize($data);
+ $data['columns'] = $field['columns'];
+ $data['indexes'] = $field['indexes'];
+
+ // Save the new data.
+ $query = db_update('field_config')
+ ->condition('id', $field['id'])
+ ->fields(array('data' => serialize($data)))
+ ->execute();
+ }
+}
+
+/**
* @} End of "defgroup field-updates-6.x-to-7.x"
*/