Skip to content

[DeepClone] Separate the storage of ArrayObject and ArrayIterator from the payload - #715

Merged
nicolas-grekas merged 1 commit into
1.xfrom
deepclone-array-object-storage
Oct 7, 2026
Merged

nicolas-grekas merged 1 commit into
1.xfrom
deepclone-array-object-storage

Conversation

@nicolas-grekas

@nicolas-grekas nicolas-grekas commented Oct 6, 2026 •

Copy link
Copy Markdown
Member
Q A
Branch? 1.x
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

ArrayObject::__serialize() and ArrayIterator::__serialize() return their storage without separating it (php/php-src#17935), so writing to the object after deepclone_to_array() changes the payload, and every clone built from it later. That breaks the snapshot DeepCloner is used for, eg the FormFlow data stored in the session.

This separates that storage right after calling __serialize(). The extension gets the same fix in symfony/php-ext-deepclone#62.

@nicolas-grekas
nicolas-grekas force-pushed the deepclone-array-object-storage branch from c56abc5 to 35039af Compare October 6, 2026 19:46
@nicolas-grekas
nicolas-grekas merged commit 6c36734 into 1.x Oct 7, 2026
40 checks passed
@nicolas-grekas
nicolas-grekas deleted the deepclone-array-object-storage branch October 7, 2026 07:18
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Oct 7, 2026
…writes to an ArrayObject (nicolas-grekas)

This PR was merged into the 8.1 branch.

Discussion
----------

[VarExporter] Fix DeepCloner snapshots changed by later writes to an ArrayObject

| Q             | A
| ------------- | ---
| Branch?       | 8.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

`ArrayObject` and `ArrayIterator` return their storage from `__serialize()` without separating it (php/php-src#17935), so writing to such an object after creating a `DeepCloner` changed the snapshot, eg the FormFlow data saved in the session. symfony/polyfill-deepclone 1.43.1 fixes it (symfony/polyfill#715), and ext-deepclone gets the same fix in symfony/php-ext-deepclone#62.

Commits
-------

345b10e [VarExporter] Fix DeepCloner snapshots changed by later writes to an ArrayObject
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.

1 participant