diff -u b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php --- b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -22,9 +22,6 @@ * * Supported settings (below the definition's 'settings' key) are: * - target_type: The entity type to reference. Required. - * - target_bundle: (optional): If set, restricts the entity bundles which may - * may be referenced. May be set to an single bundle, or to an array of - * allowed bundles. * * @FieldType( * id = "entity_reference", only in patch2: unchanged: --- a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php @@ -33,17 +33,6 @@ class ConfigurableEntityReferenceItem extends EntityReferenceItem implements Opt /** * {@inheritdoc} */ - public static function defaultStorageSettings() { - $settings = parent::defaultStorageSettings(); - // The target bundle is handled by the 'target_bundles' property in the - // 'handler_settings' instance setting. - unset($settings['target_bundle']); - return $settings; - } - - /** - * {@inheritdoc} - */ public function getPossibleValues(AccountInterface $account = NULL) { return $this->getSettableValues($account); } only in patch2: unchanged: --- a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php +++ b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php @@ -126,7 +126,6 @@ public function testFieldInstanceSettings() { // storages so we end up with the default value for this setting. 'handler' => 'default:node', 'handler_settings' => array(), - 'target_bundle' => NULL, ); $field_settings = $field->getSettings(); ksort($expected); only in patch2: unchanged: --- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php @@ -689,7 +689,7 @@ public function testEntityConstraintValidation() { $definition = BaseFieldDefinition::create('entity_reference') ->setLabel('Test entity') ->setSetting('target_type', 'node') - ->setSetting('target_bundle', 'article'); + ->setSetting('handler_settings', ['target_bundles' => ['article' => 'article']]); $reference_field = \Drupal::TypedDataManager()->create($definition); $reference = $reference_field->appendItem(array('entity' => $node))->get('entity'); $violations = $reference->validate(); only in patch2: unchanged: --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1643,5 +1643,30 @@ function system_update_8007() { } /** ++ * Removes the stale 'target_bundle' setting for entity_reference fields. ++ */ +function system_update_8008() { + $config = \Drupal::configFactory(); + /** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */ + $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); + $item_class = 'Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem'; + + // Iterate on all fields storage. + foreach ($config->listAll('field.storage.') as $field_id) { + $field_storage = $config->getEditable($field_id); + $class = $field_type_manager->getPluginClass($field_storage->get('type')); + + // Deal only with entity reference fields and descendants. + if ($class != $item_class && !is_subclass_of($class, $item_class)) { + continue; + } + + // Remove 'target_bundle' from settings. + $field_storage->clear('settings.target_bundle'); + $field_storage->save(TRUE); + } +} + +/** * @} End of "addtogroup updates-8.0.0-beta". */