Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Call getDataSource() instead of the directly calling

ConnectionManager::getDataSource().
  • Loading branch information...
commit 52d425737af584d33352ff0540dbf769006d82f5 1 parent c1f3d9c
@bar bar authored
Showing with 6 additions and 16 deletions.
  1. +6 −16 lib/Cake/Model/Datasource/DboSource.php
View
22 lib/Cake/Model/Datasource/DboSource.php
@@ -1117,11 +1117,7 @@ public function read(Model $Model, $queryData = array(), $recursive = null) {
$LinkModel = $Model->{$assoc};
if (!isset($linkedModels[$type . '/' . $assoc])) {
- if ($Model->useDbConfig === $LinkModel->useDbConfig) {
- $db = $this;
- } else {
- $db = ConnectionManager::getDataSource($LinkModel->useDbConfig);
- }
+ $db = $Model->useDbConfig === $LinkModel->useDbConfig ? $this : $LinkModel->getDataSource();
} elseif ($Model->recursive > 1) {
$db = $this;
}
@@ -1129,8 +1125,8 @@ public function read(Model $Model, $queryData = array(), $recursive = null) {
if (isset($db) && method_exists($db, 'queryAssociation')) {
$stack = array($assoc);
$stack['_joined'] = $joined;
+
$db->queryAssociation($Model, $LinkModel, $type, $assoc, $assocData, $array, true, $resultSet, $Model->recursive - 1, $stack);
- unset($db);
if ($type === 'hasMany' || $type === 'hasAndBelongsToMany') {
$filtered[] = $assoc;
@@ -1246,11 +1242,7 @@ public function queryAssociation(Model $Model, &$LinkModel, $type, $association,
$tmpStack = $stack;
$tmpStack[] = $assoc1;
- if ($LinkModel->useDbConfig === $DeepModel->useDbConfig) {
- $db = $this;
- } else {
- $db = ConnectionManager::getDataSource($DeepModel->useDbConfig);
- }
+ $db = $LinkModel->useDbConfig === $DeepModel->useDbConfig ? $this : $DeepModel->getDataSource();
$db->queryAssociation($LinkModel, $DeepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
}
@@ -1331,11 +1323,9 @@ public function queryAssociation(Model $Model, &$LinkModel, $type, $association,
if ($type1 === 'belongsTo' || ($DeepModel->alias === $modelAlias && $type === 'belongsTo') || ($DeepModel->alias !== $modelAlias)) {
$tmpStack = $stack;
$tmpStack[] = $assoc1;
- if ($LinkModel->useDbConfig == $DeepModel->useDbConfig) {
- $db = $this;
- } else {
- $db = ConnectionManager::getDataSource($DeepModel->useDbConfig);
- }
+
+ $db = $LinkModel->useDbConfig === $DeepModel->useDbConfig ? $this : $DeepModel->getDataSource();
+
$db->queryAssociation($LinkModel, $DeepModel, $type1, $assoc1, $assocData1, $queryData, true, $fetch, $recursive - 1, $tmpStack);
}
}

0 comments on commit 52d4257

Please sign in to comment.
Something went wrong with that request. Please try again.