core icon indicating copy to clipboard operation
core copied to clipboard

Many to One Relationships Not Copied in Copy Site

Open ian-b-cooper opened this issue 1 year ago • 4 comments

Parent Issue

No response

Problem Statement

When copying a site, if a content items has a many to one relationship field and the content of that relationship field lives on the system host, or another host, that relationship is not copied over when a full site copy is performed.

This severely impacts our customers who use this copy site functionality to quickly launch hundreds and thousands of sites and expect the related content to be respected upon copy.

It is important to note this is seemingly confined to the "many to one" relationship cardinality type, and is not reproducible when using "many to many".

Steps to Reproduce

Please see this video link

To reproduce, create two content types (C1, C2), each with a title and site/folder field, each living on system host. Have C2 contain a relationship field pointing at C1, with a "many to one" designation.

Create C2 on a site and ensure it has the site/folder field value of that site, not system host, then create C1 on either another site. This c1 content item can have either it's own site value selected, or system host (it will reproduce either way).

Relate that c1 content item to the C2 content item, then copy the site the C2 content item lives with "all" objects selected. When seeing the copied content item on the copied site, you will observe the relationship is no longer included.

Acceptance Criteria

The relationship must be maintained when the content item is copied during the copy site action.

dotCMS Version

23.01, demo, and latest release.

Proposed Objective

Technical User Experience

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

This is a direct request from a customer implementing core functionality for a large multitenant implemenation.

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

ian-b-cooper avatar Jul 17 '24 19:07 ian-b-cooper

This behavior, and potential changes to it, goes deeper than it appears.

After discussing this with @ian-b-cooper we decided that we'll make a first pass at this which allows the copy site API to copy all related content, including content from many-to-one relationships.

But we also need to make this behavior switchable. Copy site has worked this way for some time, and we already have some customers that use the copy site API extensively. So, there's a very real chance that it would break some customers' workflows if the behavior changes.

The upshot of all this is that:

  • Ideally, we should add an option to the API to allow customers to specify what cardinality of relationships to copy related content from (1-1, 1-N, N-1, N-M, or any combination of these).
  • If that's a significant lift, then we should change the default behavior to copy all relations by default, but add a simpler flag to support the old behavior.

john-thomas-dotcms avatar Aug 22 '24 01:08 john-thomas-dotcms

This gets fraught. Do we copy the relationships of the relationships?

wezell avatar Aug 22 '24 12:08 wezell

@wezell that's right. For the cardinalities that are working right now, such as one-to-many and many-to-many, the related content of the related content is being copied as well.

jcastro-dotcms avatar Aug 22 '24 16:08 jcastro-dotcms

NOTE TO QA:

Watch the video that Ian mentioned in the Steps to Reproduce section, which clearly illustrates how to reproduce the issue.

jcastro-dotcms avatar Aug 28 '24 20:08 jcastro-dotcms

Passed Internal QA: Followed steps in the video and now it's working as expected.

Content type with a many-to-one relationship field. Image

Content with many-to-one relationship field after being copied as part of the copy site. Image

Opening the copied content shows the related content was kept after the copy. Image

dsilvam avatar Aug 29 '24 21:08 dsilvam

Approved: Tested on trunk_a74ccb5, Docker, macOS 14.5, FF v126.0.1 Screenshot 2024-08-30 at 9 21 19 AM

josemejias11 avatar Aug 30 '24 15:08 josemejias11