-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix order array sum normalizedData and nestedData #51825
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
Fix order array sum normalizedData and nestedData #51825
Conversation
Hey! To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Previously, when `array_merge` was changed array+array in 6.3.5, the combined array result is changed as well. array_merge behaves differently than array+array. e.g.: ``` $a = ['key' => 'value-a']; $b = ['key' => 'value-b']; var_dump(array_merge($a, $b)); // Results in: // array(1) { // ["key"]=> // string(7) "value-b" // } var_dump($a + $b); // Results in: // array(1) { // ["key"]=> // string(7) "value-a" // } ``` By switching left with right, the result will be the same again.
158ca81
to
67f49d4
Compare
I've encountered the same issue and can confirm that this fixes it without (at least in my case) introducing any additional problems. |
Thank you @jerowork. |
Description
With the update of Serializer to 6.3.5, some deserialization of array to objects does behave differently (changed order of priority of configuration via attribute
#[SerializedPath]
vs. property name, when there is a key on root level with the same name as the private property.Related to #49700.
How to reproduce
Example to explain changed behavior:
Before 6.3.5, the value of the id was
id-1
, with the change of #49700, the value of the id becomesid-2
.#49700 changes
array_merge
witharray + array
. It seems that the problem stated above is related to the fact that array_merge does overwrite keys differently than array + array:Solution
As
array_merge
does behave slightly differently that array + array, the solution could be to switch array order to:This would result in the same, while keeping the fix (#49700) for the numeric key value