From d77a19e4a4d7fd842c2a986b2b725909ee29447f Mon Sep 17 00:00:00 2001 From: phpnut Date: Sun, 5 Nov 2006 06:29:15 +0000 Subject: [PATCH] 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 --- cake/basics.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 1c64c9a5a..8be40fab0 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -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