diff -u b/core/modules/field/field.views.inc b/core/modules/field/field.views.inc --- b/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -296,10 +296,10 @@ else { $group = t('@group (historical data)', array('@group' => $group_name)); } - $column_real_name = $field['storage details']['sql'][$type][$table][$column]; + $column_real_name = $field['storage_details']['sql'][$type][$table][$column]; // Load all the fields from the table by default. - $additional_fields = array_values($field['storage details']['sql'][$type][$table]); + $additional_fields = array_values($field['storage_details']['sql'][$type][$table]); $data[$table][$column_real_name] = array( 'group' => $group, diff -u b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php --- b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php @@ -409,7 +409,7 @@ * Implements ArrayAccess::offsetExists(). */ public function offsetExists($offset) { - return isset($this->{$offset}) || in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage details')); + return isset($this->{$offset}) || in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage_details')); } /** @@ -435,7 +435,7 @@ $bundles = $this->getBundles(); return $bundles; - case 'storage details': + case 'storage_details': $this->getStorageDetails(); return $this->storageDetails; } @@ -447,7 +447,7 @@ * Implements ArrayAccess::offsetSet(). */ public function offsetSet($offset, $value) { - if (!in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage details'))) { + if (!in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage_details'))) { $this->{$offset} = $value; } } @@ -456,7 +456,7 @@ * Implements ArrayAccess::offsetUnset(). */ public function offsetUnset($offset) { - if (!in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage details'))) { + if (!in_array($offset, array('columns', 'foreign keys', 'bundles', 'storage_details'))) { unset($this->{$offset}); } } diff -u b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php --- b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -169,8 +169,8 @@ // Go through the list and determine the actual column name from field api. foreach ($options as $column) { $name = $column; - if (isset($this->field_info['storage details']['sql'][$rkey][$this->table][$column])) { - $name = $this->field_info['storage details']['sql'][$rkey][$this->table][$column]; + if (isset($this->field_info['storage_details']['sql'][$rkey][$this->table][$column])) { + $name = $this->field_info['storage_details']['sql'][$rkey][$this->table][$column]; } $fields[$column] = $name; diff -u b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php --- b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -41,27 +41,29 @@ 'type' => 'test_field', ); field_test_memorize(); - $create_field = field_create_field($field_definition); + $field = field_create_field($field_definition); $mem = field_test_memorize(); $this->assertIdentical($mem['field_test_field_create_field'][0][0]['field_name'], $field_definition['field_name'], 'hook_field_create_field() called with correct arguments.'); $this->assertIdentical($mem['field_test_field_create_field'][0][0]['type'], $field_definition['type'], 'hook_field_create_field() called with correct arguments.'); - // Read the configuration. - $field = entity_load('field_entity', $field_definition['field_name']); + // Read the configuration. Check against raw configuration data rather than + // the loaded ConfigEntity, to be sure we check that the defaults are + // applied on write. + $field_config = \Drupal::config('field.field.' . $field->id())->get(); // Ensure that basic properties are preserved. - $this->assertEqual($field['field_name'], $field_definition['field_name'], 'The field name is properly saved.'); - $this->assertEqual($field['type'], $field_definition['type'], 'The field type is properly saved.'); + $this->assertEqual($field_config['id'], $field_definition['field_name'], 'The field name is properly saved.'); + $this->assertEqual($field_config['type'], $field_definition['type'], 'The field type is properly saved.'); // Ensure that cardinality defaults to 1. - $this->assertEqual($field['cardinality'], 1, 'Cardinality defaults to 1.'); + $this->assertEqual($field_config['cardinality'], 1, 'Cardinality defaults to 1.'); // Ensure that default settings are present. $field_type = field_info_field_types($field_definition['type']); - $this->assertEqual($field['settings'], $field_type['settings'], 'Default field settings have been written.'); + $this->assertEqual($field_config['settings'], $field_type['settings'], 'Default field settings have been written.'); // Ensure that default storage was set. - $this->assertEqual($field['storage']['type'], variable_get('field_storage_default'), 'The field type is properly saved.'); + $this->assertEqual($field_config['storage']['type'], variable_get('field_storage_default'), 'The field type is properly saved.'); // Guarantee that the name is unique. try { @@ -142,7 +144,7 @@ 'type' => 'test_field', 'field_name' => 'ftvid', ); - $field = field_create_field($field_definition); + field_create_field($field_definition); $this->fail(t('Cannot create a field bearing the name of an entity key.')); } catch (FieldException $e) { @@ -232,7 +234,6 @@ $field = field_read_field($field_definition['field_name']); $schema = $field->getSchema(); $expected_indexes = array('value' => array('value')); - // @todo This is a tested behavior... indexes are supposed to be saved in the field. $this->assertEqual($schema['indexes'], $expected_indexes, 'Field type indexes saved by default'); // Check that indexes specified by the field definition override the field diff -u b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php --- b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -242,9 +242,9 @@ $instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']); // The storage details are indexed by a storage engine type. - $this->assertTrue(array_key_exists('drupal_variables', $field['storage details']), 'The storage type is Drupal variables.'); + $this->assertTrue(array_key_exists('drupal_variables', $field['storage_details']), 'The storage type is Drupal variables.'); - $details = $field['storage details']['drupal_variables']; + $details = $field['storage_details']['drupal_variables']; // The field_test storage details are indexed by variable name. The details // are altered, so moon and mars are correct for this test. diff -u b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php --- b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php @@ -49,7 +49,9 @@ function testCreateFieldInstance() { $instance = field_create_instance($this->instance_definition); - // Read the configuration. + // Read the configuration. Check against raw configuration data rather than + // the loaded ConfigEntity, to be sure we check that the defaults are + // applied on write. $config = \Drupal::config('field.instance.' . $instance->id())->get(); $field_type = field_info_field_types($this->field['type']);