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

Duplicating records removes all records duplicated from #115

Open
5in4 opened this issue Aug 14, 2023 · 2 comments
Open

Duplicating records removes all records duplicated from #115

5in4 opened this issue Aug 14, 2023 · 2 comments
Labels
issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by maintainer or multiple community members

Comments

@5in4
Copy link

5in4 commented Aug 14, 2023

Bug report

Describe the bug

When duplicating a record, the source record disappears when publishing the new record.
This happens because both records share the same vuid and are not detached from each other after duplicating. Therefore, all source records are hidden after hitting publish on the new record

Steps to reproduce the behavior

  1. Install strapi & this plugin, create a new collection type, e.g. "page"

  2. Go to a list view of any content type

  3. Create and Publish a new record

  4. Go back to list view

  5. Click on "Duplicate Item line 1" (any record)

  6. Click on "Save"

  7. Click on "Publish"

-> only the duplicated record is visible on the list view

Expected behavior

Both, source and duplicated records, are visible after duplicating.

Screenshots

image

System

  • Node.js version: v18.17.1
  • NPM version: 9.6.7
  • Strapi version: 4.12.0
  • Database: postgres & sqlite
  • Operating system: Debian & Macos

Additional context

  • this is reproducible from a clean setup with versions indicated above
  • injecting a new vuid in the beforeCreate lifecycle solves the issue, but might corrupt version history
@omikulcik
Copy link
Collaborator

Hey @5in4, thank you for reporting this bug. I was successful reproducing it. We are currently working on a release of a major version which should fix this.

@omikulcik omikulcik added issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by maintainer or multiple community members labels Aug 14, 2023
@ivoberg
Copy link

ivoberg commented Oct 31, 2023

issue is with auto-clone service that runs on duplicate
i created this patch for this but it's not good solution and I would love to know how to send to edit view the flag that it is a duplicate in order to not save a version after item already created
you can add this to a patch file and run patch-package

diff --git a/node_modules/@strapi/plugin-content-manager/server/controllers/collection-types.js b/node_modules/@strapi/plugin-content-manager/server/controllers/collection-types.js
index aae060d..6c38745 100644
--- a/node_modules/@strapi/plugin-content-manager/server/controllers/collection-types.js
+++ b/node_modules/@strapi/plugin-content-manager/server/controllers/collection-types.js
@@ -181,6 +181,8 @@ module.exports = {

     const sanitizedBody = await sanitizeFn(body);

+    sanitizedBody.vuid = uuid();
+
     const clonedEntity = await entityManager.clone(entity, sanitizedBody, model);

     ctx.body = await permissionChecker.sanitizeOutput(clonedEntity);

EDIT: vuid cannot be null, needs uuid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve status: confirmed Confirmed by maintainer or multiple community members
Projects
None yet
Development

No branches or pull requests

3 participants