|
|
@@ -1125,10 +1125,13 @@ class Model extends Object implements CakeEventListener {
|
|
|
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,
|