mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Ticket 4108
- Added schemaName to DboSource::fields() method cache key to fix bug with changing schema name
This commit is contained in:
parent
ad0944c491
commit
0f7d6a90a1
2 changed files with 23 additions and 0 deletions
|
@ -2281,6 +2281,7 @@ class DboSource extends DataSource {
|
||||||
$fields,
|
$fields,
|
||||||
$quote,
|
$quote,
|
||||||
ConnectionManager::getSourceName($this),
|
ConnectionManager::getSourceName($this),
|
||||||
|
$model->schemaName,
|
||||||
$model->table
|
$model->table
|
||||||
);
|
);
|
||||||
$cacheKey = md5(serialize($cacheKey));
|
$cacheKey = md5(serialize($cacheKey));
|
||||||
|
|
|
@ -945,6 +945,28 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEquals(2, count(DboTestSource::$methodCache['fields']));
|
$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
|
* Test that group works without a model
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue