Skip to content
Permalink
Browse files

Fixing fatal error caused by associated models using a datasource tha…

…t is not a subclass of dbo_source. Test added. Fixes #873
  • Loading branch information...
markstory committed Jul 11, 2010
1 parent 1033461 commit 65efd675c1a471d644add491cb96565ed74b3e36
@@ -841,7 +841,7 @@ function read(&$model, $queryData = array(), $recursive = null) {
$db =& $this;
}
if (isset($db)) {
if (isset($db) && method_exists($db, 'queryAssociation')) {
$stack = array($assoc);
$db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1, $stack);
unset($db);
@@ -1339,6 +1339,7 @@ function getLastQuery() {
function endTest() {
unset($this->Model);
Configure::write('debug', $this->debug);
ClassRegistry::flush();
unset($this->debug);
}
@@ -4441,4 +4442,19 @@ function testFullTablePermutations() {
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'tbl_articles');
}
/**
* test that read() only calls queryAssociation on db objects when the method is defined.
*
* @return void
*/
function testReadOnlyCallingQueryAssociationWhenDefined() {
ConnectionManager::create('test_no_queryAssociation', array(
'datasource' => 'data'
));
$Article =& ClassRegistry::init('Article');
$Article->Comment->useDbConfig = 'test_no_queryAssociation';
$result = $Article->find('all');
$this->assertTrue(is_array($result));
}
}

0 comments on commit 65efd67

Please sign in to comment.
You can’t perform that action at this time.