Permalink
Browse files

Adding import()s to DbConfigTask and ModelTask to fix missing class e…

…rrors, when methods are run in certain orders.
  • Loading branch information...
1 parent f81d3da commit 5f1d090bf0227d91fe1a4024d682c9f24ea88cba @markstory markstory committed Nov 4, 2009
Showing with 8 additions and 11 deletions.
  1. +2 −1 cake/console/libs/tasks/db_config.php
  2. +6 −10 cake/console/libs/tasks/model.php
View
3 cake/console/libs/tasks/db_config.php
@@ -353,9 +353,10 @@ function bake($configs) {
* @return void
**/
function getConfig() {
+ App::import('Model', 'ConnectionManager', false);
+
$useDbConfig = 'default';
$configs = get_class_vars($this->databaseClassName);
-
if (!is_array($configs)) {
return $this->execute();
}
View
16 cake/console/libs/tasks/model.php
@@ -76,16 +76,6 @@ class ModelTask extends Shell {
var $__validations = array();
/**
- * startup method
- *
- * @return void
- **/
- function startup() {
- App::import('Model', 'Model', false);
- parent::startup();
- }
-
-/**
* Execution method always used for tasks
*
* @access public
@@ -176,6 +166,8 @@ function inOptions($options, $prompt = null, $default = null) {
* @access private
*/
function __interactive() {
+ App::import('Model', 'Model', false);
+
$this->hr();
$this->out(sprintf("Bake Model\nPath: %s", $this->path));
$this->hr();
@@ -796,6 +788,8 @@ function getTable($modelName, $useDbConfig = null) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
+ App::import('Model', 'ConnectionManager', false);
+
$db =& ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
$fullTableName = $db->fullTableName($useTable, false);
@@ -823,6 +817,8 @@ function getAllTables($useDbConfig = null) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
+ App::import('Model', 'ConnectionManager', false);
+
$tables = array();
$db =& ConnectionManager::getDataSource($useDbConfig);
$usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix'];

0 comments on commit 5f1d090

Please sign in to comment.