Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
When the option for updating matching content is enabled, some types of content items may not be reliably identified as unique matches. Examples of these include Paragraph and Media entities. The default logic matches entities based on the immediate properties of the entity, but in these cases the properties may be more limited and cause false matches resulting in accidental overwrites.
Proposed resolution
Expand the logic in the entityExists()
method to handle difficult entity types with more targeted logic.
Comment | File | Size | Author |
---|---|---|---|
#4 | media_default-2893055-4.patch | 631 bytes | kbasarab |
Comments
Comment #2
kbasarab CreditAttribution: kbasarab commentedThe other item that happens with media items is multiples get generated instead of re-using the existing one. Not sure where this is occurring yet but something I'll be looking into.
If you create a media entity separately that media entity gets generated each time ycip runs instead of updating existing. If adding a mid value then a duplicate entry error occurs.
Comment #3
slucero@kbasarab, that's actually coming from the
entityExists()
method that needs to be expanded here. Specifically at this line Media entities are excluded from matching and thereby updating.I'm working on a bit of revamping for loading and searching for entities overall which will also play into loading menu and taxonomy parents that should ease some of this, but even with that more targeted logic for handling Paragraph and Media entities needs to be implemented.
Comment #4
kbasarab CreditAttribution: kbasarab commentedAhh that makes sense. Found that line also when I started exploring in. I did a quick test and at least in the use case I'm working with all the media entities are basing off of the core media_field_data fields so querying on mid, bundle and name is enough to stop duplicates and make proper references in reference process callbacks.
Patch attached to comment out the media special case temporarily.
Comment #5
sluceroWork for improving the logic used to identify and match against existing entities should take into account the efforts being tracked in #2949625: Move Entity Loading and Lookup into Helper Service to extract this existing work out of
ContentLoader
into a separateEntityLoadHelper
service.Expanding this logic also relates directly to the expansion into supporting configuration of this process described in #2894614: Allow configuration of properties used to match existing entities.
For ongoing efforts related to this issue specifically, sub-tasks targeting specific content/entity types should likely be broken out from this issue to better focus and guide these efforts.
Next steps