Permalink
Browse files

Only enable cacheSources if both the datasource + model agree on it.

This prevents models from flipping cacheSources on when the datasource
has it disabled already.

Refs #2364
  • Loading branch information...
markstory committed Nov 19, 2013
1 parent 99fd6e4 commit ec38ee1c4800d150e8ee9684e613f718a8a972ba
Showing with 5 additions and 4 deletions.
  1. +2 −1 lib/Cake/Model/Model.php
  2. +3 −3 lib/Cake/Test/Case/Model/ModelIntegrationTest.php
View
@@ -843,6 +843,7 @@ public function __isset($name) {
}
}
+
if (!$className) {
return false;
}
@@ -1128,7 +1129,7 @@ public function setSource($tableName) {
if (method_exists($db, 'listSources')) {
$restore = $db->cacheSources;
- $db->cacheSources = $this->cacheSources;
+ $db->cacheSources = ($restore && $this->cacheSources);
$sources = $db->listSources();
$db->cacheSources = $restore;
@@ -155,17 +155,17 @@ public function testPkInHabtmLinkModelArticleB() {
}
/**
- * Tests that $cacheSources can only be disabled in the db using model settings, not enabled
+ * Tests that $cacheSources is restored despite the settings on the model.
*
* @return void
*/
- public function testCacheSourcesDisabling() {
+ public function testCacheSourcesRestored() {
$this->loadFixtures('JoinA', 'JoinB', 'JoinAB', 'JoinC', 'JoinAC');
$this->db->cacheSources = true;
$TestModel = new JoinA();
$TestModel->cacheSources = false;
$TestModel->setSource('join_as');
- $this->assertFalse($this->db->cacheSources);
+ $this->assertTrue($this->db->cacheSources);
$this->db->cacheSources = false;
$TestModel = new JoinA();

0 comments on commit ec38ee1

Please sign in to comment.