Needs work
Project:
Corresponding Entity References
Version:
5.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Feb 2021 at 12:43 UTC
Updated:
24 Jan 2025 at 06:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sutharsan commentedThis approach can not be correct, it fixes the immediate message, but introduces broken references to the deleted entity. Deleting the references to an entity which is being deleted was introduced in #2888077: Wont delete reference if referenced entity is the entity being deleted, the fix should be in that realm.
Comment #3
ethant@sutharsan, the delete hook introduced in #2888077 introduces fatal errors. In this instance, I think the solution for addressing the issue raised in #2888077 creates a bigger problem than that which it is addressing.
Comment #4
replicaobscura@EthanT While I agree that we don't want to throw unhandled exceptions, I don't think removing the entire delete hook that was just added is the right solution. This would make the entire patch from that issue useless, and would re-open that issue.
Instead, it seems like we should either solve the specific exception you are running into in a way that doesn't disable the deletion handling, re-think how the deletion handling works, or revert the entire patch from the linked issue instead of just part of it.
Comment #5
anybodyWould someone please be so kind to create a MR based on #4?
Comment #6
caspervoogt commentedIn my case, I have a site with users containing CER fields, meaning I can't delete users while the that CER is enabled. My workaround is to temporarily disable the CER, delete the users, then re-enable the CER.
Comment #7
heine commentedThis bug happens when other delete hooks run while cer_entity_delete is in flight, for instance when deleting certain referenced items on hook_entity_delete that have a cer controlled field.
This causes \Drupal\cer\Entity\CorrespondingReference::synchronizeCorrespondingFields() to run with a list of entities that are in the loader cache, but no longer exist. EntityStorageBase won't be able to load the original anymore, causing $entity->original to be empty, triggering the exception.
I found that calling the following and checking for non-null during the inner loop in \Drupal\cer\Entity\CorrespondingReference::synchronizeCorrespondingFields() fixes the issue for that particular site.
Comment #8
anybody@heine could you prepare a MR for that?
Comment #9
dhruv.mittal commentedComment #10
dhruv.mittal commentedI tried to reproduce the issue by deleting a content having corresponding reference field.I'm attaching a video FYR.
But couldn't able to reproduce it so I'm unassigned myself from the issue. I think this issue is fixed in the newer release.
Thank you.
Comment #11
dhruv.mittal commented