core
core copied to clipboard
Copy folder duplicates content on pages
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:
- Create an Advance Template
- Click on Add Container and add the Rich Text Container.
- Delete the unique ID, so it looks like this:
#parseContainer('d71d56b4-0a8b-4bb2-be15-ffa5a23366ea','1')
- Save the Template
- Create a Folder
- Create a page in the folder with the created template.
- Add content to the page.
- Go back to the site browser
- Right-click over the folder
- Mark for Copy
- Right-click over the site
- Paste
- Open the
_copy
folder - Open the page
- 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
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 - 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
PR: #22976
LGTM! https://monosnap.com/file/y7nGPJN2KUi3OcnC2pe6rSBZn4yGKs
Approved QA - Tested on 22.09_a506dc69_SNAPSHOT // Docker // macOS 12.6 FF 105.0.1