diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index ae6e006..55c225f 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -352,33 +352,36 @@ function taxonomy_update_8006() { * Update taxonomy_term_reference field tables to use target_id instead of tid. */ function taxonomy_update_8007() { - // @todo Switch to the update-safe version of this function when we have one. - if (!$fields = field_read_fields(array('type' => 'taxonomy_term_reference'), array('include_inactive' => 1))) { - return; - } + foreach (config_get_storage_names_with_prefix('field.field.') as $config_name) { + $field_config = config($config_name); + // Only update taxonomy reference fields that use the default SQL storage. + if ($field_config->get('type') == 'taxonomy_term_reference' && $field_config->get('storage.type') == 'field_sql_storage') { + $field_id = $field_config->get('id'); + $field = array( + // _field_sql_storage_tablename() still relies on the 'field_name' + // property. + 'field_name' => $field_id, + 'deleted' => FALSE, + ); - foreach ($fields as $field_name => $field) { - if ($field['storage']['type'] != 'field_sql_storage') { - // Field doesn't use SQL storage, we cannot modify the schema. - continue; - } + $tables = array( + _field_sql_storage_tablename($field), + _field_sql_storage_revision_tablename($field), + ); - $tables = array( - _field_sql_storage_tablename($field), - _field_sql_storage_revision_tablename($field), - ); + foreach ($tables as $table_name) { + db_change_field($table_name, $field_id . '_tid', $field_id . '_target_id', array( + 'description' => 'The ID of the target entity.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + )); - foreach ($tables as $table_name) { - db_change_field($table_name, $field_name . '_tid', $field_name . '_target_id', array( - 'description' => 'The ID of the target entity.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => FALSE, - )); + // Change the index. + db_drop_index($table_name, $field_id . '_tid'); + db_add_index($table_name, $field_id . '_target_id', array($field_id . '_target_id')); + } - // Change the index. - db_drop_index($table_name, $field_name . '_tid'); - db_add_index($table_name, $field_name . '_target_id', array($field_name . '_target_id')); } } }