- Issue created by @peterwcm
- 🇮🇳India arunsahijpal
Hi @peterwcm,
I've updated the createDuplicate method please check.Also @berdir pls check is this a good solution?
Thanks,
Arun - 🇹🇼Taiwan peterwcm
Hi @arunsahijpal,
Thanks for working on this. The patch fixes the issue, but it causes orphaned paragraphs to be created before users save the node. I think there could be issues with translations as well.
I'm puzzled about the
!$item->entity->isNew()
condition, as it seemed to work fine without it before. Could we consider removing that condition instead? @berdirRegards
Peter
- 🇮🇳India arunsahijpal
@peterwcm,
I've updated the code and now no more orphaned paragraphs and everything saves when the node saves by referencing the entity directly instead of manually setting target_id.
and I also think this condition!$item->entity->isNew()
is not necessary.
For the translation thing there is one limitation that - Paragraphs are referenced entities, not simple text fields.
Drupal does not natively support translating entity reference fields.
When I tried to translate it shows this error* (unsupported) Paragraphs fields do not support translation
. Yo can checkout this link → for more info .
I think there is one tot check translation with Paragraphs Library module but I'm not sure.
Could you pls check it, if it works then I think we can safely remove that condition. - 🇹🇼Taiwan peterwcm
Hi @arunsahijpal,
Thanks for addressing this so quickly.
I just did some quick tests, and the latest patch has fixed the issues. - Status changed to RTBC
about 16 hours ago 3:03pm 8 May 2025 - 🇨🇭Switzerland berdir Switzerland
The check is in preparation for the new hook in Drupal 11.2 to avoid additional duplication. The changes remove the relevant todo and there is no test coverage for the bug that this seems to fix.
We have fairly extensive duplication tests, if there is a bug then that should be covered by tests.
- 🇵🇹Portugal dxvargas
This problem is not happening when using drupal core 11.2 In this case, the
\Drupal\paragraphs\Hook\EntityHooks::duplicate
is doing the job.
@peterwcm, @arunsahijpal can you please tell us if you're using a version of drupal prior to 11.2? - 🇵🇹Portugal dxvargas
Still, I want to confirm that there is a bug when using Drupal core prior to 11.2 (when the new hook "entity_duplicate" is not run).
It happens when we duplicate a new introduced paragraph (with nested paragraphs).
In that case the new condition!$item->entity->isNew()
is FALSE and the nested paragraphs are not duplicated. They end up being used in the original and in the duplicated paragraph.
Sorry that I can't provide a test ATM.Just removing the new condition
!$item->entity->isNew()
fixes this. - 🇹🇼Taiwan peterwcm
Hi @dxvargas,
Yes, we are now using Drupal 10.4.6. I couldn't remember the version I tested when using simplytest.me, but looking at the options, it would also be prior to Drupal 11.