diff options
author | Andrey Andreev <narf@devilix.net> | 2017-06-27 15:31:17 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2017-06-27 15:31:17 +0200 |
commit | 894a3f2c9fe111af35dee4f5e8e711259b893fb6 (patch) | |
tree | 77d201cb4f92101461167f82604a2c2aadc92711 /system/core | |
parent | 763b7703ee744b65878bbf721fce3e5ec4dfac82 (diff) |
Fix #5164
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Loader.php | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index 5ed6adb48..7be5fd41b 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1037,6 +1037,26 @@ class CI_Loader { return $this->_ci_load_stock_library($class, $subdir, $params, $object_name); } + // Safety: Was the class already loaded by a previous call? + if (class_exists($class, FALSE)) + { + $property = $object_name; + if ( ! isset($property)) + { + $property = strtolower($class); + isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$object_name]; + } + + $CI =& get_instance(); + if (isset($CI->$property)) + { + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; + } + + return $this->_ci_init_library($class, '', $params, $object_name); + } + // Let's search for the requested library file and load it. foreach ($this->_ci_library_paths as $path) { @@ -1047,27 +1067,8 @@ class CI_Loader { } $filepath = $path.'libraries/'.$subdir.$class.'.php'; - - // Safety: Was the class already loaded by a previous call? - if (class_exists($class, FALSE)) - { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) - { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_library($class, '', $params, $object_name); - } - } - - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; - } // Does the file exist? No? Bummer... - elseif ( ! file_exists($filepath)) + if ( ! file_exists($filepath)) { continue; } |