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.
If you have a translatable node with a paragraph, deleting one of the translations causes that content of node is deleted. For instance, create a paragraphed content type in any language, add Translation(s) to it into desired language. After deleting translation (with non-Original language), content is erased.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff-2832592-5-7.txt | 2.03 KB | ModernMantra |
#7 | TEST_ONLY-2832592-7.patch | 2.1 KB | ModernMantra |
#5 | TEST_ONLY.patch | 1.69 KB | ModernMantra |
Comments
Comment #2
michaellander CreditAttribution: michaellander at Elevated Third commentedThe problem may be within
Drupal\paragraphs\Plugin\Field\FieldWidget::initIsTranslating()
, when removing:I was able to create separate translated nested paragraphs. However I'm not familiar enough with this piece to know what purpose that statement is serving.
Comment #3
miro_dietikerThis is indeed critical and needs a fix and extended test coverage.
Even if people don't know how to fix it, writing a test for it would be a great start.
Comment #4
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedDiscussed with @berdir, and seems that this bug report is related to Meta issue 'Support translatable paragraph entity reference revision field'. As @berdir suggests, this issue should go in slightly chnaged direction. Namely, we should fix the problem 'when translation is deleted, content is gone'. So will soon provide a test coverage for that.
Comment #5
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedDone testing in UI with @berdir, and paragraph is erased in node when changing translation, however tests show totally different. Strange...
Comment #6
BerdirI said deleting a translation, that's something very different than changing the language.
Also, the title and issue summary needs to be updated.
Comment #7
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedHere is new test only patch that makes deleting translation. Hope that steps in tests are good. Also changed summary and title.
Comment #8
BerdirThat looks better, should fail now.
The code that actually deletes is in \Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::delete()
delete() is called per-translation. We should open a new issue in ERR that is related to this. We have existing API tests there in \Drupal\entity_reference_revisions\Tests\EntityReferenceRevisionsCompositeTest::testEntityReferenceRevisionsCompositeRelationship() where ew delete.
We need to extend that with API tests for this.
Note that to delete a translation, what you need to do on the API is call removeTranslation() and then save().
We should test those two things on the API level:
1. Create an entity like done there with a composite, add a translation. Delete the entity. This must delete the composite.
2. Create an entity like it does there with a composite, add a translation. Delete the translation. This must not delete. Then delete the entity, now we must delete the composite.
Thinking about it, this might even be a core issue, but we still need test coverage in ERR anyway, so start with that.
The core issue might be somewhere in \Drupal\Core\Entity\ContentEntityStorageBase::invokeFieldMethod(). We should not call a delete() on a non-translatable field at all there. If you can write a test, then I can look into this later today.
Comment #9
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedSo, created an issue in ERR, soon will be test there.
Comment #10
miro_dietikerCommitted the related ERR issue.
Can someone please provide a summary of the current (remaining) status of this issue and how to move forward?
Comment #11
BerdirWe could write paragraph specific test coverage to ensure it works here as expected as well but there is no bug anymore.
Comment #12
michaellander CreditAttribution: michaellander at Elevated Third commentedThis issue originally started because nested paragraphs were shared between translations instead of them being separate for each, has that issue been addressed?
It turned into an issue about deleting one translation deletes both, but that was occurring because the translations weren't recursively applying to nested paragraph entities.
Comment #13
BerdirParagraphs does not support translated fields (yet). There's a separate issue to introduce that feature but for now, it doesn't work at all. And if you use that patch, then you need to report bugs there in that issue.
Comment #14
michaellander CreditAttribution: michaellander at Elevated Third commentedThanks @Berdir. I'll follow-up there.
Comment #15
johnchqueNot urgent because it is fixed but tests are needed anyway.
Comment #16
supertony CreditAttribution: supertony commented@ yongt9412, in which version was this fixed? I'm using 8.x-1.1 and seeing a similar issue.
What's happening, for example, I have an English content and translated it into Chinese. I edit the English version, save the page and everything is deleted from the original node.