Problem/Motivation

If the replicate module is enabled, unlinking a paragraph from the library, that paragraph entity will be duplicated with the \Drupal\replicate\Replicator::replicateEntity() method, which saves the entity unnecessarily. I faced this problem, when checked, if the paragraph isNew() and wanted to add or hide dropdown actions according to that. Since the \Drupal\Core\Entity\Entity::createDuplicate() marks the entity as new, when using the replicate module, the case should be the same. Also preventing to have orphaned paragraphs is also a good thing.

Proposed resolution

Use the \Drupal\replicate\Replicator::cloneEntity() method instead of the replicateEntity(). The result will be the same since the replicateEntity() method is also using the cloneEntity(), but the paragraph won't be saved, after cloning it.

Remaining tasks

User interface changes

API changes

Data model changes

Original report by [username]

Comments

arpad.rozsa created an issue. See original summary.

arpad.rozsa’s picture

Status: Active » Needs review
StatusFileSize
new894 bytes
berdir’s picture

Status: Needs review » Needs work

I think there is at least one additional usage of this in the main module that we should update in the same way.

arpad.rozsa’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB
new715 bytes

Yes, you are right there is one in the ParagrahsWidget::duplicateSubmit() method. Updated it also.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, existing test coverage shows this still works, we can't easily explicitly test for this.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

OK then, committed it this way, thank you. :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.