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

[5.x] Use deep copy of objects in replicator set #11621

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

faltjo
Copy link
Contributor

@faltjo faltjo commented Mar 25, 2025

This PR fixes #11619

Instead of a shallow copy, a deep copy of the (default) values is used when adding or duplicating an item in the replicator-set.

Unfortunately I do not know how to test this in an automated way.

When using statamic from this branch, the problems are gone in the example repo: https://github.com/faltjo/replicator-set-bug

@faltjo faltjo changed the title [5.x] use deep copy of objects in replicator set (#11619) [5.x] use deep copy of objects in replicator set Mar 25, 2025
Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change clone(value) to JSON.parse(JSON.stringify(value)) ? And let me know if that still resolves the issue on your site.

We a bunch of changes regarding clone() in the current v6 branch, and I don't want this to accidentally get reverted. Better to be explicit here for now.

@faltjo
Copy link
Contributor Author

faltjo commented Mar 26, 2025

Sure. It still resolves the issue, I added the commit accordingly.

@duncanmcclean duncanmcclean changed the title [5.x] use deep copy of objects in replicator set [5.x] Use deep copy of objects in replicator set Mar 26, 2025
@jasonvarga jasonvarga merged commit b1201eb into statamic:5.x Mar 26, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replicator set uses same object for child entries
2 participants