Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elements and ElementalAreas duplicated when restoring page from archived state #1093

Closed
AljosaB opened this issue Aug 30, 2023 · 1 comment
Closed

Comments

@AljosaB
Copy link
Contributor

AljosaB commented Aug 30, 2023

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
Copy link
Member

PR merged. Thanks for sorting that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants