Skip to content

[5.x] Clone internal data collections #11777

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

jacksleight
Copy link
Contributor

@jacksleight jacksleight commented May 9, 2025

The classes that use ContainsData and ContainsSupplementalData store their data as collection objects not plain arrays. Because of this when you clone an entry object the clone still points to the same data collection object, so if you set something on the clone it also gets set on the original (same for supplemental data).

This PR fixes that by cloning the internal data collections when the main objects are cloned.

It also clones the user group roles, and the localised term term (as that's required to clone the term data).

It also adds a couple of missing $this->supplements = collect(); constructor lines.

@edalzell
Copy link
Contributor

edalzell commented May 9, 2025

yaaas, I had to work around this in my Events addon

@jasonvarga jasonvarga merged commit 78b37a4 into statamic:5.x May 13, 2025
30 checks passed
@jacksleight jacksleight deleted the fix/cloned-internal-collections branch May 13, 2025 20:31
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.

3 participants