diff options
author | Andrey Andreev <narf@devilix.net> | 2016-01-11 11:09:52 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2016-01-11 11:09:52 +0100 |
commit | 38b08116c61c0a68e6d350c986f75589220692ed (patch) | |
tree | fa8a9b5a0f0be955d42110b67037d1ff46e54604 /system/core | |
parent | 34251bfec2627fb0526d5f99f3a13a3d8a4506d8 (diff) | |
parent | fd5fe1a64c03ae7204a7e72d936215f7a61d8c30 (diff) |
Merge branch '3.0-stable' into develop
Resolved conflicts:
system/database/drivers/mysql/mysql_driver.php
system/database/drivers/mysqli/mysqli_driver.php
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Loader.php | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index 18e4c5287..87f21b279 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -285,9 +285,39 @@ class CI_Loader { $this->database($db_conn, FALSE, TRUE); } + // Note: All of the code under this condition used to be just: + // + // load_class('Model', 'core'); + // + // However, load_class() instantiates classes + // to cache them for later use and that prevents + // MY_Model from being an abstract class and is + // sub-optimal otherwise anyway. if ( ! class_exists('CI_Model', FALSE)) { - load_class('Model', 'core'); + $app_path = APPPATH.'core'.DIRECTORY_SEPARATOR; + if (file_exists($app_path.'Model.php')) + { + require_once($app_path.'Model.php'); + if ( ! class_exists('CI_Model', FALSE)) + { + throw new RuntimeException($app_path."Model.php exists, but doesn't declare class CI_Model"); + } + } + elseif ( ! class_exists('CI_Model', FALSE)) + { + require_once(BASEPATH.'core'.DIRECTORY_SEPARATOR.'Model.php'); + } + + $class = config_item('subclass_prefix').'Model'; + if (file_exists($app_path.$class.'.php')) + { + require_once($app_path.$class.'.php'); + if ( ! class_exists($class, FALSE)) + { + throw new RuntimeException($app_path.$class.".php exists, but doesn't declare class ".$class); + } + } } $model = ucfirst($model); |