The bug is due to the order of the switch cases in the loadProxyClass function in the ProxyFactory.php file.
When the the file has changed, the code falls through to the second case which just checks if the file exists and then breaks, so it never reached the final case.
I have annotated the troublesome code below with "[BUG Explanation]":
switch ($this->autoGenerate) {
case self::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED:
if (file_exists($fileName) && filemtime($fileName) >= filemtime($class->getReflectionClass()->getFileName())) {
break;
}
// [BUG Explanation]: It correctly falls through here to the next case, when the file has changed
case self::AUTOGENERATE_FILE_NOT_EXISTS:
if (file_exists($fileName)) {
// [BUG Explanation]: It reaches this point, because the files exists
break;
}
case self::AUTOGENERATE_ALWAYS:
// [BUG explanation] It never reaches this point and so the proxy is not generated.
$this->generateProxyClass($class, $fileName, $proxyClassName);
break;
}
Bug Report
Summary
The
AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED
setting forsetAutoGenerateProxyClasses
does not update the proxy files.The bug is here.
The bug is due to the order of the switch cases in the
loadProxyClass
function in the ProxyFactory.php file.When the the file has changed, the code falls through to the second case which just checks if the file exists and then breaks, so it never reached the final case.
I have annotated the troublesome code below with "[BUG Explanation]":
Again, the code is here.
Current behavior
The proxy classes are not updated automatically, even when their Entity class files are updated, due to the error outlined above.
How to reproduce
$config
$config->setAutoGenerateProxyClasses(ProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED)
Expected behavior
The proxy file is updated when the entity class file has changed.
Thank you.