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
@@ -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])) {
@@ -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]);