mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
Undefined array key when calling refresh() after updating to 2.20.1 #7459
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mcapinha-mxp on GitHub (Jan 8, 2025).
Bug Report
Summary
After updating to 2.20.1, in some circumstances, calling
refresh()on an Entity returns anUndefined array keyerrorCurrent behavior
When calling
refresh()on an entity, anUndefined array keyexception is thrown.Expected behavior
The entity should be refreshed from the db and no error shown.
How to reproduce
I haven't been able to produce a minimal reproducible example, probably because our Entity setup is very complex.
However, reverting the changes in blem solves the issue for us.
@mcapinha-mxp commented on GitHub (Jan 8, 2025):
Here's a stack trace from our Symfony application:
@mcapinha commented on GitHub (Jan 11, 2025):
Hello.
I add a test that reproduces this issue in 2.20.1 and passes in 2.20.0.
AFAICT, this reproduces what our application is doing at the point the error is triggered.
The commit is in this branch in my forked repo:
https://github.com/mcapinha/orm/tree/2.20.1_refresh_issue
Can you please have a look?
@greg0ire commented on GitHub (Jan 11, 2025):
cc @goetas
@goetas commented on GitHub (Jan 11, 2025):
Thanks for the super well prepared reproducer.
This is an interesting edgecase present in past versions of doctrine.
It happens because an there is an attempt to refresh an entity that has not yet been flushed (thus not in the database).
What is the expected behavior of this code?
Currently most doctrine versions will trigger the error
Undefined array key.... If you use a database that supports sequences you might get e different error (did not spend time verifying it).I see at least two options.
option 2 seems the most backward compatible approach, 3 seems the best (a little more complex but not that much)
@greg0ire commented on GitHub (Jan 11, 2025):
Maybe 2 + a deprecation, and then 1 in doctrine 4?
@joey-bolts commented on GitHub (Mar 25, 2025):
This might be related to https://github.com/doctrine/orm/pull/10065