core icon indicating copy to clipboard operation
core copied to clipboard

Copy folder duplicates content on pages

Open erickgonzalez opened this issue 2 years ago • 4 comments

Describe the bug If you copy a folder that contains a page, the content in the copied page is duplicated.

Note: only shows duplicated if the container in the template doesn't have a unique ID. If it has an unique ID it duplicates the content but not showing in UI.

To Reproduce Steps to reproduce the behavior:

  1. Create an Advance Template
  2. Click on Add Container and add the Rich Text Container.
  3. Delete the unique ID, so it looks like this: #parseContainer('d71d56b4-0a8b-4bb2-be15-ffa5a23366ea','1')
  4. Save the Template
  5. Create a Folder
  6. Create a page in the folder with the created template.
  7. Add content to the page.
  8. Go back to the site browser
  9. Right-click over the folder
  10. Mark for Copy
  11. Right-click over the site
  12. Paste
  13. Open the _copy folder
  14. Open the page
  15. See the duplicated content

Note: check the DB you'll see that the page has 2 content related, one entry shows the relation_type as LEGACY_RELATION_TYPE.

Expected behavior Copying folders shouldn't duplicate content on pages.

Workaround Create the folder manually and only copy the pages.

Reproducible in 5.3.8 LTS, 21.06 LTS and demo (22.08). Customer ticket https://dotcms.zendesk.com/agent/tickets/108105

erickgonzalez avatar Aug 15 '22 20:08 erickgonzalez

These lines are the ones that are duplicating the content with the LEGACY_RELATION_TYPE https://github.com/dotCMS/core/blob/master/dotCMS/src/main/java/com/dotmarketing/portlets/folders/business/FolderFactoryImpl.java#L493-L497

I remove these lines locally and test, and it fixes the issue. It doesn't create the other entry with the wrong relation_type.

erickgonzalez avatar Aug 15 '22 20:08 erickgonzalez

@erickgonzalez - don't be afraid to push your changes in a branch, even if it is temporary - to help with debugging and getting the fix done

wezell avatar Aug 16 '22 13:08 wezell

PR: #22976

nollymar avatar Sep 14 '22 00:09 nollymar

LGTM! https://monosnap.com/file/y7nGPJN2KUi3OcnC2pe6rSBZn4yGKs

alfredo-dotcms avatar Sep 19 '22 17:09 alfredo-dotcms

Approved QA - Tested on 22.09_a506dc69_SNAPSHOT // Docker // macOS 12.6 FF 105.0.1

josemejias07 avatar Sep 23 '22 15:09 josemejias07