Elements and ElementalAreas duplicated when restoring page from archived state
Closed this issue · 1 comments
AljosaB commented
Setup
Elemental + Fluent as described in advanced documentation
Steps to Reproduce
- create a page, add any element and remember element's ID
- archive page
- restore page
- check element's (new) ID
Issue
public function onBeforeWrite()
{
parent::onBeforeWrite();
if (!$this->isDraftedInLocale() && $this->isInDB()) {
$elementalArea = $this->ElementalArea();
$elementalAreaNew = $elementalArea->duplicate();
$this->ElementalAreaID = $elementalAreaNew->ID;
}
return;
}
When page is being restored the code above gets triggered and duplicates elemental area and it's elements (cascade_duplicates on elemental area). This is not a desired state in my opinion as it can potentially break some things. For example you could have an ElementVirtual linking to element and relying on it's ID to stay the same.
PRs
GuySartorelli commented
PR merged. Thanks for sorting that out.