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

[Content Manager][i18n] Duplicate translated entity keep relation with duplicated entity #20091

Open
Slashgear opened this issue Apr 11, 2024 · 7 comments
Assignees
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@Slashgear
Copy link

Slashgear commented Apr 11, 2024

Bug report

Required System information

  • Node.js version: 20.11
  • Yarn version: 3.8.1
  • Strapi version: 2.21.0
  • Database: postgres 13.3
  • Operating system: Macos 14.3.1
  • Is your project Javascript or Typescript: Javascript

Describe the bug

Duplication of an entity in the content manager with entity using i18n plugin activated will have a strange behaviour of keep the relation to cloned entity.

sequenceDiagram
    actor User as User
    User->>+StrapiAdmin: Click on duplicate button
    StrapiAdmin->>Controller: Forge a http query to the collection-types.ts `autoClone` method
    Controller->>EntityManager: Call entity manager clone method
    EntityManager->>Controller: Return new entity with `localization` object copied from cloned one
    Controller->>StrapiAdmin: Show a translation alternative in the cloned entity
    StrapiAdmin->>User: Don't permit user to contribute be able to create an alternative language of his entity as it already exist
Loading

Steps to reproduce the behavior

  1. Go to content manager
  2. Open entity which has i18n activated
  3. Click on duplicate/clone button in ListEntity
  4. Clone entity has a link to the cloned entity translations

Expected behavior

A clear and concise description of what you expected to happen.

  • 💡 Ignore automatically localization relation during the cloning process in the entity manager

Screenshots

If applicable, add screenshots to help explain your problem.

Screen.Recording.2024-04-11.at.15.14.44.mov

Code snippets

If applicable, add code samples to help explain your problem.

Additional context

Add any other context about the problem here.

  • @strapi/plugin-i18n 4.21.1
@willempie96

This comment was marked as spam.

@Barik85

This comment was marked as spam.

@joshuaellis joshuaellis added issue: bug Issue reporting a bug source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information labels May 14, 2024
@david-vaclavek
Copy link

david-vaclavek commented May 23, 2024

Hello. Localazy Strapi Plugin users experienced the same issue as @Barik85 stated.

Operating System: macOS
Node.js version:  18.15.0
NPM version: 9.5.0
Strapi version: 4.24.0
Database: postgres
"@strapi/plugin-i18n": "4.24.0"

@derrickmehaffy derrickmehaffy added the severity: medium If it breaks the basic use of the product but can be worked around label May 23, 2024
@MaxLmqr
Copy link

MaxLmqr commented Jun 19, 2024

Hello.

The expected behaviour would be to have the internationalized content duplicated as well, or not duplicated at all, but it should definitely not link the entity to the same translation.

Right now, the same translated entity is used to link both based entity. We can see it in the database, where the linked ID is the same on the duplicated content. This result in the user being unable to even modify or delete the internationalized entity, because it would affect the initial entity. It prevents the duplication of a base entity to be used.

@strapi-bot
Copy link

This issue has been mentioned on Strapi Community Forum. There might be relevant details there:

https://forum.strapi.io/t/duplicate-translated-entity-keep-relation-with-duplicated-entity-4-month-old-bug/40090/1

@grdevd
Copy link

grdevd commented Jul 29, 2024

If anyone is interested, here's a patch (hack) to this problem.

diff --git a/node_modules/@strapi/strapi/dist/services/entity-service/index.js b/node_modules/@strapi/strapi/dist/services/entity-service/index.js
index 7254905..2531362 100644
--- a/node_modules/@strapi/strapi/dist/services/entity-service/index.js
+++ b/node_modules/@strapi/strapi/dist/services/entity-service/index.js
@@ -259,6 +259,11 @@ const createDefaultImplementation = ({
         contentType: model
       }
     );
+
+    if(Array.isArray(entityData.localizations)) {
+      entityData.localizations = [];
+    }
+
     let entity = await db.query(uid).clone(cloneId, {
       ...query,
       data: entityData

@sparrow-chik-chrk
Copy link

I confirm, I faced the same issue. Is there any solution?

@grdevd If it solves the problem, did you create a pull request? I’d like it to be added to the repository.

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: medium If it breaks the basic use of the product but can be worked around source: core:content-manager Source is core/content-manager package status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
Status: To be reviewed
Development

No branches or pull requests