Closed valkars closed 3 months ago
Are you using https://github.com/doctrine/persistence/releases/tag/3.3.2 ?
"name": "doctrine/persistence",
"version": "3.3.1",
Please update.
Update to 3.3.2 does not help, error remains
Because bug in ProxyFactory, not in Persistence package
Oh right, I read too fast, and I think your fix is correct :thinking: , in fact I'm a bit surprised I didn't contribute it after contributing https://github.com/doctrine/persistence/pull/348 (which was already in 3.3.1)
I see you're using 3.1.0, maybe this is just a matter of merging up and releasing a new version, let me check.
Nope, it's not contributed to 2.x yet. Please send a PR :pray:
I think this only affects 3.1.x, because this is the branch where I contributed https://github.com/doctrine/orm/pull/11330
Made a PR
Bug Report
Summary
I'll use simulated example. We have 2 entities (Cart, Customer) with OneToOne join. Customer entity has PHP Enum field. I fetch Cart from database, get Customer (receive proxy object), make copy with clone. When I try to access data of cloned entity - there is fatal error:
Typed property ReflectionProperty::$name must not be accessed before initialization
in Doctrine\ORM\Proxy\ProxyFactory line 237.In that cycle $property is a Doctrine\Persistence\Reflection\EnumReflectionProperty object and $name variable is not initialized. EnumReflectionProperty has method getName() - using this method in ProxyFactory solves the problem.
Possible fix:
Current behavior
Fatal error
How to reproduce
2 entities, enum object and example to reproduce:
Expected behavior
No errors