mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making DboSource::fields() use cacheMethod() so it respects $cacheMethods.
Test added. Fixes #1211
This commit is contained in:
parent
077d1c5ad5
commit
498417203b
2 changed files with 17 additions and 3 deletions
|
@ -1958,8 +1958,8 @@ class DboSource extends DataSource {
|
|||
$quote
|
||||
);
|
||||
$cacheKey = crc32(serialize($cacheKey));
|
||||
if (isset($this->methodCache[__FUNCTION__][$cacheKey])) {
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey];
|
||||
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
|
||||
return $return;
|
||||
}
|
||||
$allFields = empty($fields);
|
||||
if ($allFields) {
|
||||
|
@ -2049,7 +2049,7 @@ class DboSource extends DataSource {
|
|||
if (!empty($virtual)) {
|
||||
$fields = array_merge($fields, $this->_constructVirtualFields($model, $alias, $virtual));
|
||||
}
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = array_unique($fields);
|
||||
return $this->cacheMethod(__FUNCTION__, $cacheKey, array_unique($fields));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4577,4 +4577,18 @@ class DboSourceTest extends CakeTestCase {
|
|||
$result = $Article->find('all');
|
||||
$this->assertTrue(is_array($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that fields() is using methodCache()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testFieldsUsingMethodCache() {
|
||||
$this->testDb->cacheMethods = false;
|
||||
$this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty');
|
||||
|
||||
$Article =& ClassRegistry::init('Article');
|
||||
$this->testDb->fields($Article, null, array('title', 'body', 'published'));
|
||||
$this->assertTrue(empty($this->testDb->methodCache['fields']), 'Cache not empty');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue