Merge pull request #1683 from andydhobbs/ticket-4108

Fix fields cache to depend on the schemaName as well.

Fixes #4108
This commit is contained in:
Mark Story 2013-09-26 07:04:55 -07:00
commit ad1b80645d
2 changed files with 23 additions and 0 deletions

View file

@ -2281,6 +2281,7 @@ class DboSource extends DataSource {
$fields,
$quote,
ConnectionManager::getSourceName($this),
$model->schemaName,
$model->table
);
$cacheKey = md5(serialize($cacheKey));

View file

@ -945,6 +945,28 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals(2, count(DboTestSource::$methodCache['fields']));
}
/**
* test that fields() method cache detects schema name changes
*
* @return void
*/
public function testFieldsCacheKeyWithSchemanameChange() {
Cache::delete('method_cache', '_cake_core_');
DboSource::$methodCache = array();
$Article = ClassRegistry::init('Article');
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$first = $ds->fields($Article);
$Article->schemaName = 'secondSchema';
$ds = $Article->getDataSource();
$ds->cacheMethods = true;
$second = $ds->fields($Article);
$this->assertEquals(2, count(DboSource::$methodCache['fields']));
}
/**
* Test that group works without a model
*