Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Follow-up from: #2834034: Deleting a translation deletes composite references on translatable fields
A composite entity that is in a translatable field, should be deleted when the parent is deleted.
Tests exist already for this.
Proposed resolution
Uncomment the tests and fix.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#27 | interdiff-2834374-27-22.txt | 850 bytes | mbovan |
#27 | 2834374-27.patch | 1.4 KB | mbovan |
| |||
#22 | interdiff-2834374-22-18.txt | 2.75 KB | mbovan |
#22 | 2834374-22.patch | 1.41 KB | mbovan |
| |||
#22 | 2834374-22-3016388-60-COMBINED.patch | 37.4 KB | mbovan |
Comments
Comment #2
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedReferring to comment , providing possible fix for the problem.
Comment #3
JeroenTComment #4
BerdirPlease uncomment the corresponding @todo in the new test as well.
Comment #5
BerdirAlso I think this is actually the wrong issue for this change. We'll see that with the corresponding @todo.
Comment #6
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedUncommented test and provided possible fix. Also discarding previous patch since it was not relevant as said.
Comment #8
BerdirObviously this is not correct. You can't just remove the existing logic.
Comment #9
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedComment #11
miro_dietikerI think the goal here is not clear. Before doing more implementations, please update the summary and clearly express the goal and wait for confirmation / discussion.
Comment #12
johnchqueUpdated IS.
Comment #13
johnchqueIs it me or this is already fixed?
Anyway, uncommenting tests. :)
Comment #15
johnchqueOK, sorry, this is the right approach.
Comment #16
johnchqueSorry, typo.
Comment #17
BerdirNote that we need to be *very* sure here that we are not deleting something that is still used, e.g. because a translation was copied.
We need to run a query and look for somehting else referencing this paragraph and if that is the case, not delete it. We also need test for that.
Comment #18
idebr CreditAttribution: idebr at ezCompany commented#17.1
The translations of the composite entity are being deleted in #2834314: Support deleting translations of a composite reference . This leaves only the use case where the host entity is being deleted entirely. Unfortunately, there is currently no way to determine if the fieldItem is being deleted because an entity delete or a translation delete. This creates a dependency on a core patch: #2834384: Inconsistency: in FieldItem::delete we do not know if we are deleting the parent or only removing a translation. I suggest we postpone this issue until the Core issue is resolved.
#17.2
This was determined by miro_dietiker to be out of scope in #2852522-8: Deletion of referenced entities on host delete, without checking usage/another reference, since composite entities are assumed to be part of a single parent entity. Did I interpret this correctly or should be incorporate the query from the related issue?
Comment #20
miro_dietiker#17.2 "Something else" would be a previous revision of the parent owning host. I think that other kinds of ER references or even non-composite ERR wouldn't be relevant to determine if delete should be performed. Otherwise core would need to adopt entity usage tracking for delete validation as well...
Note though that the parent entity (not only the field) could vary across revisions.
Comment #21
idebr CreditAttribution: idebr at ezCompany commented#20 There is test coverage for maintaining composite entities for earlier revisions of the host entity in EntityReferenceRevisionsCompositeTest::testEntityReferenceRevisionsCompositeRelationship
Would you like to add coverage for changing the parent field / entity for composite entities in this issue? To me it feels a bit of out scope since a composite entity would be something like Paragraphs that are specifically tied to a host entity's field. It was not mentioned in earlier issues either, specially #2834314: Support deleting translations of a composite reference and #2834034: Deleting a translation deletes composite references on translatable fields
Comment #22
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedThis patch follows the same approach as #2953650: Composite entities are not removed on host delete if reference was removed in prior revision by relying on APIs that are going to be available with #3016388: Manual cleanup process for obsolete composite entities.
Thus, it is a different approach compared to #18.
Comment #24
mbovan CreditAttribution: mbovan at MD Systems GmbH commented#2953650: Composite entities are not removed on host delete if reference was removed in prior revision adds
$cron
variable in the tests and that is the reason for test fails in #22.Comment #25
mbovan CreditAttribution: mbovan at MD Systems GmbH commented#3016388: Manual cleanup process for obsolete composite entities was committed.
Comment #26
Berdirwe seem to be missing a word in the comment, lets fix that as we touch it anyway.
Comment #27
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedRerolled #22 after #2953650: Composite entities are not removed on host delete if reference was removed in prior revision and addressed #26
Comment #28
BerdirCommitted, thanks.