From ec88bd9c8c4fa385b94d07b8100413f81c98e627 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 29 Dec 2009 22:23:03 -0500 Subject: [PATCH] Forcing ModelTask to always reload schema for models when baking. Also setting the dbo's cacheSources = false so table listings are always fresh as well. --- cake/console/libs/tasks/model.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 9be466056..08ddb3b97 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -186,7 +186,7 @@ class ModelTask extends Shell { if (in_array($useTable, $this->__tables)) { $tempModel = new Model(array('name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection)); - $fields = $tempModel->schema(); + $fields = $tempModel->schema(true); if (!array_key_exists('id', $fields)) { $primaryKey = $this->findPrimaryKey($fields); } @@ -447,7 +447,7 @@ class ModelTask extends Shell { $this->out(__('One moment while the associations are detected.', true)); } - $fields = $model->schema(); + $fields = $model->schema(true); if (empty($fields)) { return false; } @@ -487,7 +487,7 @@ class ModelTask extends Shell { * @return array $associations with belongsTo added in. */ function findBelongsTo(&$model, $associations) { - $fields = $model->schema(); + $fields = $model->schema(true); foreach ($fields as $fieldName => $field) { $offset = strpos($fieldName, '_id'); if ($fieldName != $model->primaryKey && $fieldName != 'parent_id' && $offset !== false) { @@ -562,7 +562,7 @@ class ModelTask extends Shell { $foreignKey = $this->_modelKey($model->name); foreach ($this->__tables as $otherTable) { $tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable); - $modelFieldsTemp = $tempOtherModel->schema(); + $modelFieldsTemp = $tempOtherModel->schema(true); $offset = strpos($otherTable, $model->table . '_'); $otherOffset = strpos($otherTable, '_' . $model->table); @@ -695,7 +695,7 @@ class ModelTask extends Shell { $possible = array(); foreach ($this->__tables as $otherTable) { $tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection)); - $modelFieldsTemp = $tempOtherModel->schema(); + $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { if ($field['type'] == 'integer' || $field['type'] == 'string') { $possible[$otherTable][] = $fieldName; @@ -821,6 +821,7 @@ class ModelTask extends Shell { $tables = array(); $db =& ConnectionManager::getDataSource($useDbConfig); + $db->cacheSources = false; $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix']; if ($usePrefix) { foreach ($db->listSources() as $table) {