diff -u b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php --- b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php @@ -48,13 +48,12 @@ $this->drupalLogin($web_user); // Create a field with settings to validate. - $this->field_definition = array( + $this->field = field_create_field(array( 'field_name' => drupal_strtolower($this->randomName()), 'type' => 'datetime', 'settings' => array('datetime_type' => 'date'), - ); - $this->field = field_create_field($this->field_definition); - $this->instance_definition = array( + )); + $this->instance = field_create_instance(array( 'field_name' => $this->field['field_name'], 'entity_type' => 'test_entity', 'bundle' => 'test_bundle', @@ -64,8 +63,7 @@ 'settings' => array( 'default_value' => 'blank', ), - ); - $this->instance = field_create_instance($this->instance_definition); + )); $this->display_options = array( 'type' => 'datetime_default', @@ -281,15 +279,13 @@ function testDefaultValue() { // Change the field to a datetime field. - $this->field = $this->field_definition; $this->field['settings']['datetime_type'] = 'datetime'; field_update_field($this->field); // Set the default value to 'now'. - $this->instance = $this->instance_definition; $this->instance['settings']['default_value'] = 'now'; $this->instance['default_value_function'] = 'datetime_default_value'; - $this->instance = field_update_instance($this->instance); + field_update_instance($this->instance); // Display creation form. $date = new DrupalDateTime(); @@ -305,7 +301,6 @@ $this->assertNoFieldByName("{$this->field['field_name']}[$langcode][0][value][time]", '', 'Time element found.'); // Set the default value to 'blank'. - $this->instance = $this->instance_definition; $this->instance['settings']['default_value'] = 'blank'; $this->instance['default_value_function'] = 'datetime_default_value'; field_update_instance($this->instance); diff -u b/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc --- b/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -153,7 +153,7 @@ if ($include_deleted) { $deleted_fields = state()->get('field.field.deleted') ?: array(); foreach ($deleted_fields as $id => $config) { - $fields[$id] = new Field($config, 'field_entity'); + $fields[$id] = entity_create('field_entity', $config); } } @@ -339,8 +339,8 @@ if ($include_deleted) { $deleted_fields = state()->get('field.field.deleted'); $deleted_instances = state()->get('field.instance.deleted') ?: array(); - foreach ($deleted_instances as $id => $instance) { - $instances[$id] = new FieldInstance($instance, 'field_instance'); + foreach ($deleted_instances as $id => $config) { + $instances[$id] = entity_create('field_instance', $config); } } diff -u b/core/modules/field/field.install b/core/modules/field/field.install --- b/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -249,6 +249,8 @@ 'block' => 8008, // - User pictures have been turned to fields. 'user' => 8011, + // - The {file_usage}.id column has moved to varchar. + 'file' => 8001, ); return $dependencies; } @@ -432,10 +434,13 @@ $deleted_instances[$config['uuid']] = $config; } - // Update file_usage table in case this instance has a default image. + // Update {file_usage} table in case this instance has a default image. if (!empty($config['settings']['default_image'])) { db_update('file_usage') ->fields(array('id' => $config['field_uuid'])) + ->condition('type', 'default_image') + ->condition('module', 'image') + ->condition('id', $instance['field_id']) ->condition('fid', $config['settings']['default_image']) ->execute(); } diff -u b/core/modules/field/field.module b/core/modules/field/field.module --- b/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -821,8 +821,8 @@ /** * Generate an a table id for deleted fields. * - * When a field is a deleted, the tables are renamed to {field_data_field_id} - * and {field_revision_field_id}. To make sure we don't end up with table + * When a field is a deleted, the tables are renamed to {field_data_FIELD_UUID} + * and {field_revision_FIELD_UUID}. To make sure we don't end up with table * names longer than 64 characters, we hash the uuid and return the first * 6 characters so we end up with a short unique id. * diff -u b/core/modules/file/file.install b/core/modules/file/file.install --- b/core/modules/file/file.install +++ b/core/modules/file/file.install @@ -234,21 +234,6 @@ } /** - * Implements hook_update_dependencies(). - */ -function file_update_dependencies() { - // The update hook to convert the id column in the column table needs to be - // the first one because user update hooks will be called during system - // update hooks due to other dependencies and the user picture conversion - // might need to save a default image and the field it's stored in, does - // not have an integer id anymore. - $dependencies['system'][8001] = array( - 'file' => 8001, - ); - return $dependencies; -} - -/** * Converts default_file_main variable to config. * * @ingroup config_upgrade @@ -262,7 +247,7 @@ } /** - * Convert the id column in file_usage to store UUID's. + * Convert the 'id' column in {file_usage} to accept UUIDs. */ function file_update_8001() { $spec = array( reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -24,7 +24,7 @@ * Tests normal formatter display on node display. */ function testNodeDisplay() { + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $type_name = 'article'; $field_settings = array( 'display_field' => '1', reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php @@ -23,7 +23,7 @@ * Tests the normal formatter display on node display. */ function testUploadPath() { + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $type_name = 'article'; $field = $this->createFileField($field_name, $type_name); $test_file = $this->getTestFile('text'); reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php @@ -31,7 +31,7 @@ * Tests RSS enclosure formatter display for RSS feeds. */ function testFileFieldRSSContent() { + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $type_name = 'article'; $field_settings = array( 'display_field' => '1', reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -32,7 +32,7 @@ */ function testRevisions() { $type_name = 'article'; + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -27,7 +27,7 @@ */ function testRequired() { $type_name = 'article'; + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name, array(), array('required' => '1')); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); @@ -75,7 +75,7 @@ */ function testFileMaxSize() { $type_name = 'article'; + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name, array(), array('required' => '1')); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); @@ -127,7 +127,7 @@ */ function testFileExtension() { $type_name = 'article'; + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); diff -u b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php --- b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -32,7 +32,7 @@ */ function testSingleValuedWidget() { $type_name = 'article'; - $field_name = 'test_file_field'; + $field_name = strtolower($this->randomName()); $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); @@ -88,7 +88,13 @@ */ function testMultiValuedWidget() { $type_name = 'article'; - $field_name = 'test_file_field'; + // Use explicit names instead of random names for those fields, because of a + // bug in drupalPost() with multiple file uploads in one form, where the + // order of uploads depends on the order in which the upload elements are + // added to the $form (which, in the current implementation of + // FileStorage::listAll(), comes down to the alphabetical order on field + // names). + $field_name = 'test_file_field_1'; $field_name2 = 'test_file_field_2'; $this->createFileField($field_name, $type_name, array('cardinality' => 3)); $this->createFileField($field_name2, $type_name, array('cardinality' => 3)); @@ -205,7 +211,7 @@ */ function testPrivateFileSetting() { $type_name = 'article'; - $field_name = 'test_file_field'; + $field_name = strtolower($this->randomName()); $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -38,7 +38,7 @@ */ function testPrivateFile() { $type_name = 'article'; + $field_name = strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name, array('uri_scheme' => 'private')); // Create a field with no view access - see field_test_field_access(). reverted: --- b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -31,7 +31,7 @@ // Create file field. $type_name = 'article'; + $field_name = 'field_' . strtolower($this->randomName()); - $field_name = 'test_file_field'; $this->createFileField($field_name, $type_name); $field = field_info_field($field_name); $instance = field_info_instance('node', $field_name, $type_name); diff -u b/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc --- b/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/translation_entity/translation_entity.admin.inc @@ -14,7 +14,7 @@ * * @param \Drupal\field\Plugin\Core\Entity\Field $field * A field definition array. - * @param Drupal\field\Plugin\Core\Entity\FieldInstance $instance + * @param \Drupal\field\Plugin\Core\Entity\FieldInstance $instance * A field instance definition object. * * @return array