diff --git a/core/modules/field/field.module b/core/modules/field/field.module index a720c4d..9e0c2c6 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -269,6 +269,9 @@ function field_entity_create(EntityInterface $entity) { * Defaults to the entity language. */ function field_populate_default_values(EntityInterface $entity, $langcode = NULL) { + // Ensure we are working with a BC mode entity. + $entity = $entity->getBCEntity(); + $entity_type = $entity->entityType(); $langcode = $langcode ?: $entity->language()->langcode; foreach (field_info_instances($entity_type, $entity->bundle()) as $field_name => $instance) { diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php index 3944639..949a108 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php @@ -49,9 +49,13 @@ function _generateTestFieldValues($cardinality) { * (Optional) the name of the column to check. */ function assertFieldValues(EntityInterface $entity, $field_name, $langcode, $expected_values, $column = 'value') { - $e = clone $entity; - field_attach_load('test_entity', array($e->ftid => $e)); - $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array(); + // Re-load the entity to make sure we have the latest changes. + entity_get_controller($entity->entityType())->resetCache(array($entity->id())); + $e = entity_load($entity->entityType(), $entity->id()); + $field = $values = $e->getTranslation($langcode, FALSE)->$field_name; + // Filter out empty values so that they don't mess with the assertions. + $field->filterEmptyValues(); + $values = $field->getValue(); $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.'); foreach ($expected_values as $key => $value) { $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));