- Issue created by @dsdeiz
- 🇵🇭Philippines dsdeiz
I have added an MR although it probably only works for newly installed module. Existing installs most likely needs an upgrade path. What I did is store entity_id as just regular integer and added a field formatter that renders the field the same as an entity reference label.
- 🇪🇸Spain pcambra Asturies
We could add a branch 3.x maybe? @dsdeiz could you create a MR? I see a branch but not the MR
- Status changed to Needs review
about 2 months ago 8:12am 26 November 2024 - 🇪🇸Spain pcambra Asturies
I don't see how changing an ER field to an integer will solve this, sorry. An entity reference field should support any number of entities
- 🇨🇳China 司南
In fact, entity_reference field type need a fixed entity type to be configured, that is, entity_reference doesn't support dynamic entity type, contrib module dynamic_entity_reference → provide a field type which support dynamic entity type.
But using instead of dynamic_entity_reference will make big change to current branch code. if consider to use dynamic_entity_reference, we can create a new branch 3.x.
as we can see, change entity_reference to integer is a compatible solution can directlly aplly to branch 2.x, it won't break any current design, and just a bug fix.
- 🇨🇳China 司南
This change need a hook_update_N() implementation to migrate an exist site:
1. backup the data of entity_id field.
2. uninstall the entity_id field of entity_reference type.
3. create a new entity_id field with integer field type.
4. import backup data to the new field. - 🇨🇳China 司南
There are two task here.
First, "entity_id field missing target_type setting default to node", and it also make jsonapi of core functionality not work. unless we change the entity_id field from entity_reference to integer. This is a bug fix for current branch 2.x.Second, if we want to make entity_id field a reference field, we need to use dynamic_entity_reference, but it bring much change, so we should create a new branch for this.
- 🇨🇳China 司南
We notice that, changing entity_id field from entity_reference type to integer type doesn't bring database field type change, they both are an int database field.
So it doesn't need a hook_update_N() implementation. - 🇪🇸Spain pcambra Asturies
Please don't add unrelated commits here, D11 is being handled in 📌 Automated Drupal 11 compatibility fixes for like Needs review
I'm also a bit confused on why we're doing this, seems that ✨ Allow Like Entity to support multiple entity types Active is asking for using dynamic ER which would do exactly the same thing.