Ticket 4108

- Added schemaName to DboSource::fields() method cache key to fix bug with changing schema name
This commit is contained in:
Andy Hobbs 2013-09-26 11:56:14 +01:00
parent ad0944c491
commit 0f7d6a90a1
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
*