diff --git a/core/modules/block/block.install b/core/modules/block/block.install index 01c5779..114ba90 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -32,7 +32,7 @@ function block_update_dependencies() { ); // Migrate users.data after User module prepared the tables. $dependencies['block'][8005] = array( - 'user' => 8016, + 'user' => 8014, ); return $dependencies; } diff --git a/core/modules/field/field.install b/core/modules/field/field.install index dcf2b38..13d88ee 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -9,13 +9,17 @@ use Drupal\field\Plugin\Core\Entity\Field; /** - * Creates a field by writing directly to the database. + * Creates a field by writing directly to configuration. * * @ingroup update_api */ function _update_7000_field_create_field(&$field) { - // Merge in default values.` + $uuid = new Uuid(); + + // Merge in default values. $field += array( + 'id' => $field['field_name'], + 'uuid' => $uuid->generate(), 'entity_types' => array(), 'cardinality' => 1, 'translatable' => FALSE, @@ -24,62 +28,28 @@ function _update_7000_field_create_field(&$field) { 'indexes' => array(), 'deleted' => FALSE, 'active' => TRUE, + 'status' => 1, + 'langcode' => 'und', ); - // Set storage. + // Set the storage. $field['storage'] = array( 'type' => 'field_sql_storage', - 'settings' => array(), 'module' => 'field_sql_storage', 'active' => TRUE, + 'settings' => array(), ); - // 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. - $data = $field; - unset($data['columns'], $data['field_name'], $data['type'], $data['active'], $data['module'], $data['storage_type'], $data['storage_active'], $data['storage_module'], $data['locked'], $data['cardinality'], $data['deleted']); - // Additionally, do not save the 'bundles' property populated by - // field_info_field(). - unset($data['bundles']); - - // Write the field to the database. - $record = array( - 'field_name' => $field['field_name'], - 'type' => $field['type'], - 'module' => $field['module'], - 'active' => (int) $field['active'], - 'storage_type' => $field['storage']['type'], - 'storage_module' => $field['storage']['module'], - 'storage_active' => (int) $field['storage']['active'], - 'locked' => (int) $field['locked'], - 'data' => serialize($data), - 'cardinality' => $field['cardinality'], - 'translatable' => (int) $field['translatable'], - 'deleted' => (int) $field['deleted'], - ); - // We don't use drupal_write_record() here because it depends on the schema. - $field_id = db_insert('field_config') - ->fields($record) - ->execute(); + // Save in config. + Drupal::config('field.field.' . $field['id']) + ->setData($field) + ->save(); + update_config_manifest_add('field.field', array($field['id'])); // Create storage for the field. This requires a field entity, but cannot use // the regular entity_create() function here. $field_entity = new Field($field); field_sql_storage_field_storage_create_field($field_entity); - - $field['id'] = $field_id; } /** @@ -189,37 +159,34 @@ function _update_7000_field_read_fields(array $conditions = array(), $key = 'id' } /** - * Writes a field instance directly to the database. + * Writes a field instance directly to configuration. * * @ingroup update_api */ function _update_7000_field_create_instance($field, &$instance) { + $uuid = new Uuid(); + // Merge in defaults. $instance += array( - 'field_id' => $field['id'], - 'field_name' => $field['field_name'], - 'deleted' => FALSE, 'description' => '', 'required' => FALSE, + 'id' => $instance['entity_type'] . '.' . $instance['bundle'] . '.' . $instance['field_name'], + 'uuid' => $uuid->generate(), + 'field_uuid' => $field['uuid'], + 'field_type' => $field['type'], + 'default_value' => array(), + 'default_value_function' => '', + 'settings' => array(), + 'widget' => array(), + 'status' => 1, + 'langcode' => 'und', ); - // The serialized 'data' column contains everything from $instance that does - // not have its own column and is not automatically populated when the - // instance is read. - $data = $instance; - unset($data['id'], $data['field_id'], $data['field_name'], $data['entity_type'], $data['bundle'], $data['deleted']); - - $record = array( - 'field_id' => $instance['field_id'], - 'field_name' => $instance['field_name'], - 'entity_type' => $instance['entity_type'], - 'bundle' => $instance['bundle'], - 'data' => serialize($data), - 'deleted' => (int) $instance['deleted'], - ); - $instance['id'] = db_insert('field_config_instance') - ->fields($record) - ->execute(); + // Save in config. + Drupal::config('field.instance.' . $instance['id']) + ->setData($instance) + ->save(); + update_config_manifest_add('field.instance', array($instance['id'])); } /** @@ -228,22 +195,6 @@ function _update_7000_field_create_instance($field, &$instance) { */ /** - * Implements hook_update_dependencies(). - */ -function field_update_dependencies() { - // Convert Field API to ConfigEntities after: - $dependencies['field'][8003] = array( - // - Custom block bodies have been turned to fields. - 'block' => 8008, - // - User pictures have been turned to fields. - 'user' => 8011, - // - The {file_usage}.id column has moved to varchar. - 'file' => 8001, - ); - return $dependencies; -} - -/** * Empty update - moved into field_update_8003(). */ function field_update_8001() { diff --git a/core/modules/field_sql_storage/field_sql_storage.install b/core/modules/field_sql_storage/field_sql_storage.install index 03390a6..f8dd684 100644 --- a/core/modules/field_sql_storage/field_sql_storage.install +++ b/core/modules/field_sql_storage/field_sql_storage.install @@ -62,18 +62,6 @@ function _update_8000_field_sql_storage_write($entity_type, $bundle, $entity_id, } /** - * Implements hook_update_dependencies(). - */ -function field_sql_storage_update_dependencies() { - // Convert storage tables after field definitions have moved to - // ConfigEntities. - $dependencies['field_sql_storage'][8000] = array( - 'field' => 8003, - ); - return $dependencies; -} - -/** * Renames the 'language' column to 'langcode' in field data tables. */ function field_sql_storage_update_8000(&$sandbox) { diff --git a/core/modules/overlay/overlay.install b/core/modules/overlay/overlay.install index 588f871..062f20b 100644 --- a/core/modules/overlay/overlay.install +++ b/core/modules/overlay/overlay.install @@ -24,7 +24,7 @@ function overlay_enable() { function overlay_update_dependencies() { // Migrate users.data after User module prepared the tables. $dependencies['overlay'][8000] = array( - 'user' => 8011, + 'user' => 8014, ); return $dependencies; } diff --git a/core/modules/user/user.install b/core/modules/user/user.install index dca417c..2bc4b19 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -373,6 +373,18 @@ function user_install_picture_field() { } /** + * Implements hook_update_dependencies(). + */ +function user_update_dependencies() { + // Convert user picture to field after the {file_usage}.id column + // has moved to varchar. + $dependencies['user'][8011] = array( + 'file' => 8001, + ); + return $dependencies; +} + +/** * @addtogroup updates-7.x-to-8.x * @{ */ @@ -707,10 +719,6 @@ function user_update_8011() { 'uri_scheme' => 'public', 'default_image' => FALSE, ), - 'storage' => array( - 'type' => 'field_sql_storage', - 'settings' => array(), - ), ); _update_7000_field_create_field($field); @@ -787,7 +795,7 @@ function user_update_8011() { 'fid' => $default_image_fid, 'module' => 'image', 'type' => 'default_image', - 'id' => $field['id'], + 'id' => $field['uuid'], 'count' => 1, )) ->execute();