Ticket #1064 (closed defect: fixed)
generateFiles option to Doctrine_Record_Generator does not regenerate existing files
| Reported by: | Jon.Collins | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.3 |
| Component: | Record | Version: | 1.0.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
Line 160 of Record/Generator.php:
if (class_exists($this->_options['className'])) {
return false;
}
If files were previously generated into an autoloaded folder, class_exists() autoloads the class and breaks out of the Doctrine_Record_Generator::initialize() method.
The goal of the statement appears to be to avoid redefining the class in the case that generateFiles = false and the class definition is eval()'d into the script by Doctrine_Record_Generator::generateClass().
At first glance it looks like the check is not necessary if generateFiles = true, in fact we do want the new class definition to be loaded eventually by Doctrine_Import_Builder::writeDefinition().
Possible fix:
if ($this->_options['generateFiles'] == false && class_exists($this->_options['className'])) {
return false;
}
This will fail at the && and avoid autoloading the class. It seems appropriate to move this to a refactored Doctrine_Record_Generator::generateClass().