diff -u b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php --- b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php @@ -70,6 +70,7 @@ 'type' => 'entity_reference', 'cardinality' => '1', )); + $field->save(); $instance = entity_create('field_instance', array( 'field_name' => 'test_field', 'entity_type' => 'test_entity', @@ -81,6 +82,7 @@ ), ), )); + $instance->save(); // Build a set of test data. // Titles contain HTML-special characters to test escaping. @@ -211,6 +213,7 @@ 'type' => 'entity_reference', 'cardinality' => '1', )); + $field->save(); $instance = entity_create('field_instance', array( 'field_name' => 'test_field', 'entity_type' => 'test_entity', @@ -222,6 +225,7 @@ ), ), )); + $instance->save(); // Build a set of test data. $user_values = array( @@ -354,6 +358,7 @@ 'type' => 'entity_reference', 'cardinality' => '1', )); + $field->save(); $instance = entity_create('field_instance', array( 'field_name' => 'test_field', 'entity_type' => 'test_entity', @@ -365,6 +370,7 @@ ), ), )); + $instance->save(); // Build a set of test data. $node_values = array( diff -u b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php --- b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php @@ -65,6 +65,7 @@ 'type' => 'entity_reference', 'cardinality' => 1, )); + $field->save(); $instance = entity_create('field_instance', array( 'field_name' => 'test_field', 'entity_type' => 'test_entity', @@ -81,6 +82,7 @@ ), ), )); + $instance->save(); // Build a set of test data. $node_values = array( diff -u b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php --- b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php @@ -50,6 +50,7 @@ 'type' => 'entity_reference', 'cardinality' => '1', )); + $field->save(); $instance = entity_create('field_instance', array( 'field_name' => 'test_field', 'entity_type' => 'test_entity', @@ -66,6 +67,7 @@ ), ), )); + $instance->save(); // Get values from selection handler. $handler = entity_reference_get_selection_handler($instance); diff -u b/core/modules/field/field.api.php b/core/modules/field/field.api.php --- b/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -207,16 +207,6 @@ } /** - * Act on field_info_cache_clear(). - * - * This hook is invoked after the field module caches are cleared. - */ -function hook_field_info_cache_clear() { - // Reset the static value that keeps track of allowed values for list fields. - drupal_static_reset('options_allowed_values'); -} - -/** * Define the Field API schema for a field structure. * * This hook MUST be defined in .install for it to be detected during @@ -1901,7 +1891,8 @@ * Whether any data already exists for this field. */ function hook_field_update_field($field, $prior_field, $has_data) { - // @todo Needs function body. + // Reset the static value that keeps track of allowed values for list fields. + drupal_static_reset('list_allowed_values'); } /** diff -u b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php --- b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php @@ -166,6 +166,18 @@ */ public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) { $field_settings = $this->getFieldSettings(); + + // The field settings include defaults for the field type. However, this + // widget is a base class for other widgets (e.g., ImageWidget) that may act + // on field types without these expected settings. + // @todo Add support for merging settings of base types to implementations + // of FieldDefinitionInterface::getFieldSettings(). + $field_settings += array( + 'display_default' => NULL, + 'display_field' => NULL, + 'description_field' => NULL, + ); + $cardinality = $this->fieldDefinition->getFieldCardinality(); $defaults = array( 'fids' => array(), @@ -182,7 +194,7 @@ '#upload_validators' => file_field_widget_upload_validators($field_settings), '#value_callback' => 'file_field_widget_value', '#process' => array_merge($element_info['#process'], array('file_field_widget_process')), - '#progress_indicator' => $field_settings['progress_indicator'], + '#progress_indicator' => $this->getSetting('progress_indicator'), // Allows this field to return an array instead of a single value. '#extended' => TRUE, // Add properties needed by file_field_widget_value() and diff -u b/core/modules/options/options.module b/core/modules/options/options.module --- b/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -214,9 +214,16 @@ } /** - * Implements hook_field_info_cache_clear(). + * Implements hook_field_update_field(). */ -function options_field_info_cache_clear() { +function options_field_update_field($field, $prior_field, $has_data) { + drupal_static_reset('options_allowed_values'); +} + +/** + * Implements hook_field_delete_field(). + */ +function options_field_delete_field($field) { drupal_static_reset('options_allowed_values'); } diff -u b/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module --- b/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -905,6 +905,7 @@ 'default_formatter' => 'taxonomy_term_reference_link', 'field item class' => 'Drupal\taxonomy\Type\TaxonomyTermReferenceItem', 'settings' => array( + 'options_list_callback' => NULL, 'allowed_values' => array( array( 'vocabulary' => '',