Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.2
-
Fix Version/s: 1.2.2
-
Component/s: Connection
-
Labels:None
Description
I've found an issue where doctrine will use the wrong connection for tables under certain conditions.
In a template, I'm doing a $sf_user->hasCredential() - which is causing this to be run in sfGuardSecurityUser,
$this->user = Doctrine::getTable('sfGuardUser')->find($id);
When this execute, the calls find themselves to Doctrine_Manager::getConnectionForComponent($componentName)
This method calls Doctrine_Core::modelsAutoload($componentName);, which fails to load the class, and returns false (no checking is done to see if it should return true).
As this fails to include the sfGuardUser classes wher the component binding goes on, the getTAble call will use the default connection, then create the table fails to use the correct connection
Doctrine_Core::getTable()
return Doctrine_Manager::getInstance()->getConnectionForComponent($componentName)->getTable($componentName);
the binding is done after the call to getConectionForComponent, as it's getTable that will ultimately cause the autoloader to pull in the table classes.
I found that if I changed the getTable function inside the Core.php file it seemed to work. Basically it forces the autoloader to load the object file, and when it does this it runs the bound connection statement to bind a table to a connection.
/** * Get the Doctrine_Table object for the passed model * * @param string $componentName * @return Doctrine_Table */ public static function getTable($componentName) { if (!class_exists($componentName)) { new $componentName(); } return Doctrine_Manager::getInstance()->getConnectionForComponent($componentName)->getTable($componentName); }