Fix changeset computation for enum arrays#10277
Conversation
|
|
||
| if ($orgValue instanceof BackedEnum) { | ||
| $orgValue = $orgValue->value; | ||
| if (! empty($class->fieldMappings[$propName]['enumType'])) { |
There was a problem hiding this comment.
if somebody is interested why I added this check, its because I want to avoid the case where we have an array and go over the whole array checking if its BackedEnum for no reason. This way, unless there are enums in the play for the given field, no checks whatsoever are performed. Likely 0 performance gains with simple enums, but large performance gain with arrays of enums.
|
@greg0ire please review |
Please explain how it is broken, and what solution you applied in the commit message. I will review when that's done. |
|
@greg0ire done |
|
@ThomasLandauer can you please test this? |
Previously, array of enums were incorrectly compared in UoW::computeChangeSet() resulting always in false positive, since the original data for comparison is fetched using ReflectionEnumProperty::getValue(), which returns the enum values, not enum objects. This fix ensures comparing the individual enum array members' values.
I have tested it on https://github.com/ThomasLandauer/doctrine-issue-10251 and it did fix the issue |
|
can we add this on 2.13.5 milestone? |
|
We usually do this right after merging. |
* 2.13.x: Fix changeset computation for enum arrays (doctrine#10277) Psalm 5.2.0 (doctrine#10291) Run tools on PHP 8.2 (doctrine#10287)
* 2.14.x: Fix changeset computation for enum arrays (doctrine#10277) Psalm 5.2.0 (doctrine#10291) Run tools on PHP 8.2 (doctrine#10287)
Fix #10251