Re-assign $db after beforeSave.

This allows model/behavior methods to change the datasource in the
beforeSave callback. If you use drivers from different SQL platforms
things will go very poorly.

Fixes #3606
This commit is contained in:
mark_story 2013-04-21 21:15:44 -04:00
parent c2c096428c
commit 62660c6706
2 changed files with 3 additions and 2 deletions

View file

@ -86,8 +86,7 @@ class ConnectionManager {
}
if (!empty(self::$_dataSources[$name])) {
$return = self::$_dataSources[$name];
return $return;
return self::$_dataSources[$name];
}
if (empty(self::$_connectionsEnum[$name])) {

View file

@ -1689,6 +1689,8 @@ class Model extends Object implements CakeEventListener {
}
}
$db = $this->getDataSource();
if (empty($this->data[$this->alias][$this->primaryKey])) {
unset($this->data[$this->alias][$this->primaryKey]);
}