orm:ensure-production-settings incorrectly reports that proxy classes are always generated #5519

Open
opened 2026-01-22 15:09:50 +01:00 by admin · 6 comments
Owner

Originally created by @BrandonDusseau on GitHub (May 4, 2017).

The console tool orm:ensure-production-settings appears to report that "Proxy Classes are always regenerating" when the proxy mode is set to AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS.

This is due to the use of a check for truthy values rather than strict checks for boolean true or the constant AbstractProxyFactory::AUTOGENERATE_ALWAYS:

if ($this->getAutoGenerateProxyClasses()) {
    throw ORMException::proxyClassesAlwaysRegenerating();
}

This may be one of two situations: either this is a bug and the production readiness tool is misreporting this case, or the string returned by the tool is simply misleading ("... are always regenerating.").

This affects Doctrine 2.5.6.

Originally created by @BrandonDusseau on GitHub (May 4, 2017). The console tool `orm:ensure-production-settings` appears to report that "Proxy Classes are always regenerating" when the proxy mode is set to `AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS`. This is due to the use of a check for truthy values rather than strict checks for boolean `true` or the constant `AbstractProxyFactory::AUTOGENERATE_ALWAYS`: if ($this->getAutoGenerateProxyClasses()) { throw ORMException::proxyClassesAlwaysRegenerating(); } This may be one of two situations: either this is a bug and the production readiness tool is misreporting this case, or the string returned by the tool is simply misleading ("... are **always** regenerating."). This affects Doctrine 2.5.6.
admin added the ImprovementMissing TestsQuestion labels 2026-01-22 15:09:50 +01:00
Author
Owner

@Ocramius commented on GitHub (May 5, 2017):

I think the tool simply wasn't adapted to the new AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS

Still, writing files in prod is not suggested, even if they are written only once. If your production environment is being hammered, the first requests will fight for writing to that location, and some may fail, so this check should probably stay as-is...

@Ocramius commented on GitHub (May 5, 2017): I think the tool simply wasn't adapted to the new `AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS` Still, writing files in prod is not suggested, even if they are written only once. If your production environment is being hammered, the first requests will fight for writing to that location, and some may fail, so this check should probably stay as-is...
Author
Owner

@BrandonDusseau commented on GitHub (May 5, 2017):

I think that's fine, but in that case I'd suggest changing the wording on that tool's return value. I lost over an hour at work trying to diagnose why it said proxies were always being generated when I did not have it set to do so. I'm probably not going to be the only case of that happening.

Also I did choose to never auto generate in production prior to filing the bug.

@BrandonDusseau commented on GitHub (May 5, 2017): I think that's fine, but in that case I'd suggest changing the wording on that tool's return value. I lost over an hour at work trying to diagnose why it said proxies were always being generated when I did not have it set to do so. I'm probably not going to be the only case of that happening. Also I did choose to never auto generate in production prior to filing the bug.
Author
Owner

@Ocramius commented on GitHub (May 8, 2017):

The wording needs to be changed, yes. Do you have any suggestions for which phrase to use for each of these flags?

@Ocramius commented on GitHub (May 8, 2017): The wording needs to be changed, yes. Do you have any suggestions for which phrase to use for each of [these flags](https://github.com/doctrine/common/blob/319c2bc0992bc6bf25bcbda4cd70695353996627/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php#L35-L70)?
Author
Owner

@BrandonDusseau commented on GitHub (May 11, 2017):

Some simple suggestions:
AUTOGENERATE_NEVER: No message, this is okay.
AUTOGENERATE_ALWAYS: "Proxy classes are always regenerating and will cause performance degradation."
AUTOGENERATE_FILE_NOT_EXISTS: "Proxy classes auto-generate if not already existing, which may lead to performance degradation or failure under load."
AUTOGENERATE_EVAL: I'm not really sure how this one works. Given the comment on it in the code, maybe a message about how it's questionable?

Sorry for the delay!

@BrandonDusseau commented on GitHub (May 11, 2017): Some simple suggestions: `AUTOGENERATE_NEVER`: No message, this is okay. `AUTOGENERATE_ALWAYS`: "Proxy classes are always regenerating and will cause performance degradation." `AUTOGENERATE_FILE_NOT_EXISTS`: "Proxy classes auto-generate if not already existing, which may lead to performance degradation or failure under load." `AUTOGENERATE_EVAL`: I'm not really sure how this one works. Given the comment on it in the code, maybe a message about how it's questionable? Sorry for the delay!
Author
Owner

@alcaeus commented on GitHub (May 11, 2017):

IIRC, AUTOGENERATE_EVAL behaves like AUTOGENERATE_ALWAYS, except that the generated code is not written to the file system then included, but run using eval. I'd give it a similar message as AUTOGENERATE_ALWAYS.

@alcaeus commented on GitHub (May 11, 2017): IIRC, `AUTOGENERATE_EVAL` behaves like `AUTOGENERATE_ALWAYS`, except that the generated code is not written to the file system then included, but run using `eval`. I'd give it a similar message as `AUTOGENERATE_ALWAYS`.
Author
Owner

@Ocramius commented on GitHub (May 16, 2017):

AUTOGENERATE_EVAL should indeed not be run in production, but at least it won't fry your drives :-)

@Ocramius commented on GitHub (May 16, 2017): `AUTOGENERATE_EVAL` should indeed not be run in production, but at least it won't fry your drives :-)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5519