Errors when new entity types are added (in certain cases)

Created on 6 December 2019, about 5 years ago
Updated 17 February 2024, 10 months ago

In certain cases, entities with dynamic_entity_reference fields will WSOD when new entity types are added (edit form, field settings form). One example of this is when using the exclude feature on the field settings. It seems in the code it's expected that all entity types' selection handler settings will be stored in the field settings, but in the case described above, only the existing entity types at the time of saving the field will be stored. Then later when the field instance or widget are being rendered/processed, the settings for new entity types are missing and errors ensue.

The best solution I can see is to just check that the field settings has that entity type stored, and if not fallback to the defaults. Patch incoming!

(Here are some error examples for people searching for this issue):

Entity Edit Form:

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "selection_handler" for route "system.entity_autocomplete" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 204 of core/lib/Drupal/Core/Routing/UrlGenerator.php). Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('system.entity_autocomplete', Object, Array, Array) (Line: 293)

Field settings / Manage Fields:

InvalidArgumentException: The setting 'handler_settings' is reserved and cannot be used. in Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase->resolveBackwardCompatibilityConfiguration() (line 135 of core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php). Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase->setConfiguration(Array) (Line: 30)
🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇨🇦Canada drclaw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024