trackOnEntityUpdate on paragraph with multivalue reference field

Created on 31 May 2024, 29 days ago

Hi,

Problem/Motivation

When I remove an entity from an entity reference field, where I have multiple entities referenced, the removed entity doesn't trigger
the USAGE_REGISTER event.

My goal is to add/remove media from a SolR index depending of their usage in the current revision of a published node.
So, when the node is updated, I need to use the USAGE_REGISTER event.

Steps to reproduce

Add an entity reference field to a content type.
Create a node, and add some entities to that field.
When you remove one entity, when going in trackOnEntityUpdate, it calls trackOnEntityCreation and because the removed entity is not present anymore, the USAGE_REGISTER is not triggered.

Proposed resolution

in trackOnEntityUpdate
modify that test to check if field values are different between current entity and the original one?
If they are the same, go with trackOnEntityCreation, if not, continue with trackOnEntityUpdate.

 if (($source_entity instanceof RevisionableInterface) &&
        $source_entity->getRevisionId() != $source_entity->original->getRevisionId() &&
        $source_entity->hasField($field_name) &&
        !$source_entity->{$field_name}->isEmpty()
      )

I can try to work on this, but I need to be sure I don't miss something else.
Any idea?

Thanks.
Have a good day,

Seb

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡«πŸ‡·France Seb_R

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

Comments & Activities

Production build 0.69.0 2024