mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Proxy generator dumps incorrect default value for enums into lazy properties defaults #6901
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 @mbabker on GitHub (Jan 12, 2022).
Originally assigned to: @kimhemsoe on GitHub.
Bug Report
Summary
When updating an app to ORM 2.11 and changing an existing string field to use enums, when the field has a default value, the proxy is incorrectly generated and results in errors similar to "ReflectionException: Class "App\Entity\Card\App\Suit" does not exist." This is because the proxy class doesn't have the leading slash to make it a FQCN, so it's treated as a relative namespace when accessed later.
Current behavior
The proxy class'
$lazyPropertiesDefaultsarray dumps defaults with a class name that's not fully qualified, resulting in a value that's perceived as a relative namespace path.How to reproduce
composer installvendor/bin/doctrine orm:generate-proxiesproxiesfolderExpected behavior
The
$lazyPropertiesDefaultsarray should use fully qualified class names to avoid class not found errors, or if it cannot support enums with lazy loading, the proxy generator skips the field.As a temporary workaround, I can move these default assignments to the class constructor.
@derrabus commented on GitHub (Jan 12, 2022):
Thank you. Would you be able to work on a bugfix?
@mbabker commented on GitHub (Jan 13, 2022):
Doubtful, anything meaningful is going to require more engine knowledge than I have.
I can monkey-patch the ProxyGenerator so it doesn't consider enums as a lazy-loadable property:
But, getting it to actually support enums is where my skills end. The issue looks to be in how
var_export()exports things and I don't have the engine or regex knowledge to be able to mess with that output and get it to fix things.@kimhemsoe commented on GitHub (Jan 13, 2022):
Can confirm that the issue is with var_export. Ex:
Simplified version of what ProxyGenerator is generation
Possible solution could prefix with preg_replace()
@beberlei commented on GitHub (Feb 2, 2022):
Please upgrade to doctrine/common 3.2.2 to fix this issue in your projects.