Permalink
Browse files

Leave db->cacheSources unaltered.

When a model uses cacheSources = false, it should not have side effects
on the datasource.

Fixes #2364
  • Loading branch information...
markstory committed Nov 19, 2013
1 parent cc94026 commit 99fd6e40fe994e836e035fc49ca151d7a04ce657
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/Cake/Model/Model.php
View
@@ -1125,10 +1125,13 @@ protected function _generateAssociation($type, $assocKey) {
public function setSource($tableName) {
$this->setDataSource($this->useDbConfig);
$db = ConnectionManager::getDataSource($this->useDbConfig);
- $db->cacheSources = ($this->cacheSources && $db->cacheSources);
if (method_exists($db, 'listSources')) {
+ $restore = $db->cacheSources;
+ $db->cacheSources = $this->cacheSources;
$sources = $db->listSources();
+ $db->cacheSources = $restore;
+
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
throw new MissingTableException(array(
'table' => $this->tablePrefix . $tableName,

0 comments on commit 99fd6e4

Please sign in to comment.