Tuesday, February 24, 2009

Core Models not loading at all

So I'm working on this project that has about 25+ models. But I have
these 3 models that use to work, and randomly stopped working. They do
not get initialized and instead the AppModel object is returned, so I
lose all my associations and custom functions, and now everything is
breaking. The 3 models are GamesSystem, TeamsGame and TeamsUser, all
HABTM models, and all the files exist.

Whenever I debug() the objects, it either displays the AppModel or
nothing at all. This is becoming a huge problem because its halting
development and I have to launch into alpha testing next week. Even
more so, the GamesSystem model is used pretty much everywhere.

I did some testing last night in my Teams controller. The following
works:

var $uses = array('TeamsUser', 'Team', 'Recruit');

The following does not:

var $uses = array('Team', 'TeamsUser', 'Recruit');
var $uses = array('TeamsUser', 'TeamsGame', 'Team', 'Recruit');

I tried the following, and both TeamsGame and TeamsUser fail and do
not initialize:

$mostPlayed = ClassRegistry::init('TeamsGame')->getMostPlayedGames();
$newlyCreated = $this->Team->getRecentlyCreated();
$largestRosters = ClassRegistry::init('TeamsUser')->getLargestRosters
();

I then went in and debugged the loadModel() method and found nothing
wrong with it, all models were being passed to ClassRegistry::init().
So then I started debugging that and got weird results different
times.

It seems these Models fail on this part, as I did not seem them being
outputted when I echod $class:

if (class_exists($class) || App::import($type, $pluginPath . $class))
{
${$class} =& new $class($settings);
} elseif ($type === 'Model') {
if ($plugin && class_exists($plugin . 'AppModel')) {
$appModel = $plugin . 'AppModel';
} else {
$appModel = 'AppModel';
}
$settings['name'] = $class;
${$class} =& new $appModel($settings);
}


Im even more confused why they fail on App::import. Anyone have any
ideas how to get these working? Its very critical that I figure this
out. Any help would be super appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: