You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #60638 [Form] Fix keep_as_list when data is not an array (MatTheCat)
This PR was merged into the 7.2 branch.
Discussion
----------
[Form] Fix `keep_as_list` when data is not an array
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix part of #57430
| License | MIT
The `CollectionType` handles not only arrays but also `ArrayAccess&Traversable`. However when setting its `keep_as_list` option, `array_values` would then be called and crash.
To avoid this, this PR reindexes the data by getting its keys and unsetting them. This is because unsetting in a loop can produce counter-intuitive results; e.g. [`ArrayIterator` would skip indexes](https://www.php.net/manual/en/arrayiterator.offsetunset.php).
Note that #57430 mentions another issue that would be fixed by #59910.
Commits
-------
6c964e7 [Form] Fix `keep_as_list` when data is not an array
0 commit comments