diff options
author | Andrey Andreev <narf@devilix.net> | 2015-03-25 12:41:02 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-03-25 12:41:02 +0100 |
commit | 8f5c1780706113c926bb7801db27dbae97d00fcf (patch) | |
tree | 63c8a0b620bba3a14d983c9be2590ff7f1a91e74 | |
parent | 7ad59209ad2443b8ea113222e3cab38ab305da92 (diff) |
Fix #3694: Packages not overriding stock libraries
Related: #3692
-rw-r--r-- | system/core/Loader.php | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php index b2eeb3b1d..254ad0d6d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1079,17 +1079,26 @@ class CI_Loader { log_message('debug', $library_name.' class already loaded. Second attempt ignored.'); return; } - elseif (file_exists(APPPATH.'libraries/'.$file_path.$library_name.'.php')) + + $paths = $this->_ci_library_paths; + array_pop($paths); // BASEPATH + array_pop($paths); // APPPATH (needs to be the first path checked) + array_unshift($paths, APPPATH); + + foreach ($paths as $path) { - // Override - include_once(APPPATH.'libraries/'.$file_path.$library_name.'.php'); - if (class_exists($prefix.$library_name, FALSE)) + if (file_exists($path = $path.'libraries/'.$file_path.$library_name.'.php')) { - return $this->_ci_init_library($library_name, $prefix, $params, $object_name); - } - else - { - log_message('debug', APPPATH.'libraries/'.$file_path.$library_name.'.php exists, but does not declare '.$prefix.$library_name); + // Override + include_once($path); + if (class_exists($prefix.$library_name, FALSE)) + { + return $this->_ci_init_library($library_name, $prefix, $params, $object_name); + } + else + { + log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name); + } } } @@ -1097,16 +1106,20 @@ class CI_Loader { // Check for extensions $subclass = config_item('subclass_prefix').$library_name; - if (file_exists(APPPATH.'libraries/'.$file_path.$subclass.'.php')) + foreach ($paths as $path) { - include_once(APPPATH.'libraries/'.$file_path.$subclass.'.php'); - if (class_exists($subclass, FALSE)) + if (file_exists($path = $path.'libraries/'.$file_path.$subclass.'.php')) { - $prefix = config_item('subclass_prefix'); - } - else - { - log_message('debug', APPPATH.'libraries/'.$file_path.$subclass.'.php exists, but does not declare '.$subclass); + include_once($path); + if (class_exists($subclass, FALSE)) + { + $prefix = config_item('subclass_prefix'); + break; + } + else + { + log_message('debug', APPPATH.'libraries/'.$file_path.$subclass.'.php exists, but does not declare '.$subclass); + } } } |