Adding more changes to improve performance. Fixes loading of Models when instance has already been created in the registry

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7527 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-08-27 16:43:15 +00:00
parent 5e11e1490b
commit 6bdc60731f
3 changed files with 10 additions and 7 deletions

View file

@ -130,7 +130,7 @@ class ClassRegistry {
return $model;
}
if (App::import($type, $plugin . $class)) {
if (class_exists($class) || App::import($type, $plugin . $class)) {
${$class} =& new $class($settings);
} elseif ($type === 'Model') {
if ($plugin && class_exists($plugin .'AppModel')) {

View file

@ -925,6 +925,9 @@ class App extends Object {
* @return boolean
*/
function __load($file) {
if (empty($file)) {
return false;
}
$_this =& App::getInstance();
if (!$_this->return && isset($_this->__loaded[$file])) {
@ -1038,7 +1041,7 @@ class App extends Object {
return array('class' => null, 'suffix' => null, 'path' => $path);
break;
case 'behavior':
$_this->import($type, 'Behavior', false);
$_this->import('Core', 'Behavior', false);
if ($plugin) {
$path = $plugin . DS . 'models' . DS . 'behaviors' . DS;
}
@ -1145,6 +1148,7 @@ class App extends Object {
*/
function __destruct() {
$_this = & App::getInstance();
if ($_this->__cache) {
$core = Configure::corePaths('cake');
unset($_this->__paths[rtrim($core[0], DS)]);

View file

@ -339,7 +339,6 @@ class Model extends Overloadable {
if ($this->primaryKey === null) {
$this->primaryKey = 'id';
}
ClassRegistry::addObject($this->alias, $this);
$this->id = $id;
@ -668,7 +667,7 @@ class Model extends Overloadable {
$this->{$type}[$assocKey]['with'] = $joinClass;
}
if (!App::import('Model', $plugin . $joinClass)) {
if (!ClassRegistry::isKeySet($plugin . $joinClass) && !App::import('Model', $plugin . $joinClass)) {
$this->{$joinClass} = new AppModel(array(
'name' => $joinClass,
'table' => $this->{$type}[$assocKey]['joinTable'],