mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
5e11e1490b
commit
6bdc60731f
3 changed files with 10 additions and 7 deletions
|
@ -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')) {
|
||||
|
@ -175,7 +175,7 @@ class ClassRegistry {
|
|||
$_this =& ClassRegistry::getInstance();
|
||||
$key = Inflector::underscore($key);
|
||||
if (array_key_exists($key, $_this->__objects) === false) {
|
||||
$_this->__objects[$key] = &$object;
|
||||
$_this->__objects[$key] =& $object;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -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)]);
|
||||
|
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in a new issue