mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding fix for loadModel() not checking for existence of model before loading
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3827 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
969676bbf9
commit
d77a19e4a4
1 changed files with 16 additions and 9 deletions
|
@ -73,7 +73,7 @@
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Loads a loadPluginController.
|
||||
* Loads all plugin models.
|
||||
*
|
||||
* @param string $plugin Name of plugin
|
||||
* @return
|
||||
|
@ -130,23 +130,30 @@
|
|||
* Loads a model by CamelCase name.
|
||||
*/
|
||||
function loadModel($name) {
|
||||
$name = Inflector::underscore($name);
|
||||
$paths = Configure::getInstance();
|
||||
if (!class_exists('AppModel')) {
|
||||
if (file_exists(APP . 'app_model.php')) {
|
||||
require(APP . 'app_model.php');
|
||||
} else {
|
||||
require(CAKE . 'app_model.php');
|
||||
}
|
||||
Overloadable::overload('AppModel');
|
||||
}
|
||||
|
||||
foreach($paths->modelPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
require($path . $name . '.php');
|
||||
return true;
|
||||
if (!class_exists($name)) {
|
||||
$className = $name;
|
||||
$name = Inflector::underscore($name);
|
||||
$paths = Configure::getInstance();
|
||||
|
||||
foreach($paths->modelPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
require($path . $name . '.php');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Loads all controllers.
|
||||
|
@ -216,7 +223,7 @@
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Loads a loadPluginController.
|
||||
* Loads a plugin's controller.
|
||||
*
|
||||
* @param string $plugin Name of plugin
|
||||
* @param string $controller Name of controller to load
|
||||
|
|
Loading…
Add table
Reference in a new issue