Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ticket 4108

- Added schemaName to DboSource::fields() method cache key to fix bug with changing schema name
  • Loading branch information...
commit 0f7d6a90a17e7d00c99e3cfd62497d0dfb40a98e 1 parent ad0944c
Andy Hobbs authored
View
1  lib/Cake/Model/Datasource/DboSource.php
@@ -2281,6 +2281,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
$fields,
$quote,
ConnectionManager::getSourceName($this),
+ $model->schemaName,
$model->table
);
$cacheKey = md5(serialize($cacheKey));
View
22 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -946,6 +946,28 @@ public function testFieldsCacheKeyWithDatasourceChange() {
}
/**
+ * 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
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.