Deletion of referenced entities on host delete, without checking usage/another reference

Created on 14 February 2017, over 7 years ago
Updated 17 April 2024, 2 months ago

If there is e.g. paragraphs entity reference in a node, and you clone the node the reference is targeting to the same (paragraph) entity. If you delete one of these nodes, the referenced entity will be deleted - independently there is another reference to it.

I think there should be a check of usage and delete referenced entity only if no other entity_reference_revision reference exists.

To reproduce:
1) add paragraph reference to your content type
2) create a node type with at least one paragraph
3) clone your node - you can use core createDuplicate() function

$node = \Drupal\node\Entity\Node::load([NID]);
$clone = $node->createDuplicate();
$clone->save();

4) delete cloned node

$clone->delete();

5) check original node - the paragraph disappears

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇭🇺Hungary szato

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024