summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-06-28 10:49:01 +0200
committerAndrey Andreev <narf@devilix.net>2017-06-28 10:49:01 +0200
commitbe0280d02a408a8b4aeb6aee10d9dd936f978ce2 (patch)
tree299ba5d5a322d01bcaa695df98125063b12ca40b
parentdb89c20721b3b66671db9ff4d3b6c9a6de352533 (diff)
#5164 fix for stock libraries
-rw-r--r--system/core/Loader.php21
-rw-r--r--tests/codeigniter/core/Loader_test.php2
2 files changed, 12 insertions, 11 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php
index cae01ed38..12922ca64 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -1041,7 +1041,7 @@ class CI_Loader {
if (class_exists($class, FALSE))
{
$property = $object_name;
- if ( ! isset($property))
+ if (empty($property))
{
$property = strtolower($class);
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
@@ -1113,16 +1113,17 @@ class CI_Loader {
$prefix = config_item('subclass_prefix');
}
- // 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)
+ $property = $object_name;
+ if (empty($property))
{
- $CI =& get_instance();
- if ( ! isset($CI->$object_name))
- {
- return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
- }
+ $property = strtolower($library_name);
+ isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
+ }
+
+ $CI =& get_instance();
+ if ( ! isset($CI->$property))
+ {
+ return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
}
log_message('debug', $library_name.' class already loaded. Second attempt ignored.');
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 241c415b3..8c5bb3021 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -99,7 +99,7 @@ class Loader_test extends CI_TestCase {
// Test reloading
unset($this->ci_obj->$name);
$this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertObjectNotHasAttribute($name, $this->ci_obj);
+ $this->assertObjectHasAttribute($name, $this->ci_obj);
// Create baseless library
$name = 'ext_baseless_lib';