-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy generator dumps incorrect default value for enums into lazy properties defaults #9371
Comments
Thank you. Would you be able to work on a bugfix? |
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: diff --git a/lib/Doctrine/Common/Proxy/ProxyGenerator.php b/lib/Doctrine/Common/Proxy/ProxyGenerator.php
index f71cb915..29e0de4a 100644
--- a/lib/Doctrine/Common/Proxy/ProxyGenerator.php
+++ b/lib/Doctrine/Common/Proxy/ProxyGenerator.php
@@ -980,6 +980,12 @@ EOT;
continue;
}
+ if (function_exists('enum_exists')) {
+ if (!$property->getType()->isBuiltin() && enum_exists($property->getType()->getName())) {
+ continue;
+ }
+ }
+
$properties[] = $name;
}
But, getting it to actually support enums is where my skills end. The issue looks to be in how |
Can confirm that the issue is with var_export. Ex:
Simplified version of what ProxyGenerator is generation Possible solution could prefix with preg_replace() |
Please upgrade to doctrine/common 3.2.2 to fix this issue in your projects. |
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'
$lazyPropertiesDefaults
array 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 install
vendor/bin/doctrine orm:generate-proxies
proxies
folderExpected behavior
The
$lazyPropertiesDefaults
array 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.
The text was updated successfully, but these errors were encountered: