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]
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | interdiff-3015756-2-4.txt | 715 bytes | arpad.rozsa |
| #4 | unlinking_paragraph_from_library-3015756-4.patch | 1.57 KB | arpad.rozsa |
| #2 | unlinking_paragraph_from_library-3015756-2.patch | 894 bytes | arpad.rozsa |
Comments
Comment #2
arpad.rozsa commentedComment #3
berdirI think there is at least one additional usage of this in the main module that we should update in the same way.
Comment #4
arpad.rozsa commentedYes, you are right there is one in the ParagrahsWidget::duplicateSubmit() method. Updated it also.
Comment #5
berdirLooks good, existing test coverage shows this still works, we can't easily explicitly test for this.
Comment #7
miro_dietikerOK then, committed it this way, thank you. :-)