Problem/Motivation
The default entity reference selection plugin (Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::createNewEntity
) doesn't validate newly created entities which could lead into potential data integrity problems. Drupal doesn't ship with broken configurations by default, but it is very easy for users to configure in a way that leads into data integrity problems. For example, adding additional required fields besides label/title for auto creatable entity type or bundle would automatically lead into data integrity problems.
Proposed resolution
- Add UI restrictions to prevent users from creating broken configurations on their sites
- Validate auto created entities in
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::createNewEntity
Steps to reproduce
- Install standard profile
- Add a required field to the tags taxonomy
- Ensure the tags field on Article autocreates entities
- Create a new article with a tag that doesn't exist.
- Verify the term is created with the new required field empty.
Remaining tasks
-
User interface changes
-
API changes
This might create some API changes since we would do more validation. However, this only happens when user has already misconfigured their site.
Data model changes
None, but this will add stricter validation validation for new data being created through the default entity reference selection plugin.