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.

CommentFileSizeAuthor
#4 media_default-2893055-4.patch631 byteskbasarab
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slucero created an issue. See original summary.

kbasarab’s picture

The 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.

slucero’s picture

@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.

kbasarab’s picture

FileSize
631 bytes

Ahh 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.

slucero’s picture

Work 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 separate EntityLoadHelper 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

  1. (Blocked) Complete refactoring in #2949625: Move Entity Loading and Lookup into Helper Service
  2. Break this issue into more targeted child issues for specific entity types