OriginalIsEquivalent failed for array types #57405
Unanswered
hussonkevin
asked this question in
Ideas
Replies: 1 comment 2 replies
-
If we deal with multi level array your ksort will not fix it. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
12.20
PHP Version
8.4
Database Driver & Version
MySQL 8.0
Description
Hello,
There's a problem with the "originalIsEquivalent" method of the "HasAttributes" trait for array types (json, array, etc.).
If I overwrite my model with the same value as the one already defined in the database, the method returns false if the order isn't the same.
This makes sense because the strict php comparison "===" also checks the order of the keys...
The problem is that when saving, the keys are sometimes/often reordered! So the "getDirty" method returns the key.
Steps To Reproduce
In the model, use the array cast and then the step to reproduce:
The fix could be the following:
Beta Was this translation helpful? Give feedback.
All reactions