silverstripe / silverstripe-elemental

Create pages in Silverstripe CMS using content blocks
http://dna.co.nz
BSD 3-Clause "New" or "Revised" License
109 stars 115 forks source link

Editing elemental items on a duplicated page edits in two pages #1197

Closed torleif closed 3 months ago

torleif commented 3 months ago

Module version(s) affected

4.9.4

Description

When you clone a page (duplicate) it results in the page having references to the elemental items you copied

How to reproduce

Steps to reproduce:

  1. right click on a page and select 'Duplicate' > 'Duplicate this page'
  2. edit an elemental item on that page
  3. the elemental item you edited will also edit the page you duplicated

Deleting the elemental item and recreating does not help, because it's the ElementalArea reference that got copied.

You have to delete the entire page and start again. Very frustrating.

Possible Solution

clone the ElementalArea during duplication

Additional Context

No response

Validations

kinglozzer commented 3 months ago

The elemental area should be duplicated:

https://github.com/silverstripe/silverstripe-elemental/blob/0093776d88a082a12dd2d1743c49b1f7ffb50501/src/Extensions/ElementalPageExtension.php#L28-L30

I can’t recreate this on Silverstripe 5.2 + Elemental 5.2, what version are you using?

GuySartorelli commented 3 months ago

Can't reproduce in CMS 4 either. The elemental area and its blocks get completely duplicated - they're separate records entirely and do not interfere with the originals.

You've ticked the "Double check that your reproduction steps work in a fresh installation of silverstripe/installer" box... but did you actually double check that?

torleif commented 3 months ago

Thanks @kinglozzer and @GuySartorelli, a coworker narrowed down the issue, it seems that the user forms module is overriding the cascade_duplicates array here: https://github.com/silverstripe/silverstripe-userforms/blob/6/code/UserForm.php#L128