It seems that entity_type_behaviors_entity_bundle_field_info (hook_entity_bundle_field_info) get's called twice in some cases.
I've noticed it when editing the languages page. admin/config/regional/content-language

In this hook the override is created (BaseFieldOverride::createFromBaseFieldDefinition()). When saving the Language page this get's called twice, and tries twice to create the override which fails.

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: &#039;base_field_override&#039; entity with ID &#039;paragraph.call_to_action.behaviors&#039; already exists. in <em class="placeholder">Drupal\Core\Entity\EntityStorageBase-&gt;doPreSave()</em> (line <em class="placeholder">482</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/EntityStorageBase.php</em>). <pre class="backtrace">Drupal\Core\Entity\EntityStorageBase-&gt;save(Object) (Line: 263)

This means we should check if the override already exists to see if we need to create it. Following core this adds a check before calling the $field = BaseFieldOverride::createFromBaseFieldDefinition() function. See Usage in https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21B...

CommentFileSizeAuthor
#3 3072832-3.patch826 bytesmallezie
#2 3072832-1.patch910 bytesmallezie

Comments

mallezie created an issue. See original summary.

mallezie’s picture

Status: Active » Needs review
StatusFileSize
new910 bytes

Patch attached.

mallezie’s picture

StatusFileSize
new826 bytes

And for silly issues like that i've enabled the automated testing ;-)

mallezie credited mheip.

mallezie’s picture

Reviewed with mheip and committed.

  • mallezie committed ca2834d on 8.x-1.x
    Issue #3072832 by mallezie, mheip: Double creation attempt of the...
mallezie’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.