Drupal\field\Plugin\Core\Entity\FieldInstance::saveNew() has code to check that an instance for that field doesn't already exist for that entiy_type+bundle (and raise an exception if that's already the case)

In practice, this just means checking that an configEntity with the same id doesn't already exist.
That is, prevent someone from doing :

entity_create('field_instance', $array)  // where $array points to an already existing FieldInstance in the current active config
  ->save();           // Overrides the FieldInstance that was already there, goodbye...

There's no real reason why this check would make sense for FieldInstance config entities only. This should be checked automatically for all config entities


alexpott’s picture

Status: Active » Closed (duplicate)