mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Fixing Model/db $cacheSources conflicts, model can now disable only. Fixes #5177
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7518 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
57e53775ff
commit
1940d8877c
2 changed files with 22 additions and 2 deletions
|
@ -694,7 +694,7 @@ class Model extends Overloadable {
|
||||||
function setSource($tableName) {
|
function setSource($tableName) {
|
||||||
$this->setDataSource($this->useDbConfig);
|
$this->setDataSource($this->useDbConfig);
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
$db->cacheSources = $this->cacheSources;
|
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
||||||
|
|
||||||
if ($db->isInterfaceSupported('listSources')) {
|
if ($db->isInterfaceSupported('listSources')) {
|
||||||
$sources = $db->listSources();
|
$sources = $db->listSources();
|
||||||
|
@ -823,7 +823,7 @@ class Model extends Overloadable {
|
||||||
function schema($field = false) {
|
function schema($field = false) {
|
||||||
if (!is_array($this->_schema) || $field === true) {
|
if (!is_array($this->_schema) || $field === true) {
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
$db->cacheSources = $this->cacheSources;
|
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
|
||||||
if ($db->isInterfaceSupported('describe') && $this->useTable !== false) {
|
if ($db->isInterfaceSupported('describe') && $this->useTable !== false) {
|
||||||
$this->_schema = $db->describe($this, $field);
|
$this->_schema = $db->describe($this, $field);
|
||||||
} elseif ($this->useTable === false) {
|
} elseif ($this->useTable === false) {
|
||||||
|
|
|
@ -5620,6 +5620,25 @@ class ModelTest extends CakeTestCase {
|
||||||
$result = $TestModel->JoinAsJoinB->findById(1);
|
$result = $TestModel->JoinAsJoinB->findById(1);
|
||||||
$this->assertEqual($result['JoinAsJoinB']['other'], $updatedValue);
|
$this->assertEqual($result['JoinAsJoinB']['other'], $updatedValue);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Tests that $cacheSources can only be disabled in the db using model settings, not enabled
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testCacheSourcesDisabling() {
|
||||||
|
$this->db->cacheSources = true;
|
||||||
|
$TestModel = new JoinA();
|
||||||
|
$TestModel->cacheSources = false;
|
||||||
|
$TestModel->setSource('join_as');
|
||||||
|
$this->assertFalse($this->db->cacheSources);
|
||||||
|
|
||||||
|
$this->db->cacheSources = false;
|
||||||
|
$TestModel = new JoinA();
|
||||||
|
$TestModel->cacheSources = true;
|
||||||
|
$TestModel->setSource('join_as');
|
||||||
|
$this->assertFalse($this->db->cacheSources);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* endTest method
|
* endTest method
|
||||||
*
|
*
|
||||||
|
@ -5630,4 +5649,5 @@ class ModelTest extends CakeTestCase {
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue