summaryrefslogtreecommitdiffstats
path: root/system/core/Loader.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-09-25 18:50:43 +0200
committerAndrey Andreev <narf@devilix.net>2017-09-25 18:50:43 +0200
commit1db998348e8850db79c4afa2d057fa31fb6bc12c (patch)
tree5e334c1b82e8be12799b729a0234f8cc0f19bb74 /system/core/Loader.php
parent4b9d8f2fa62b62616d2d1043a6faa39d40989070 (diff)
parent4131d42c793c3db50b6184e5084332d5415c91cb (diff)
Merge branch '3.1-stable' into develop
Diffstat (limited to 'system/core/Loader.php')
-rw-r--r--system/core/Loader.php72
1 files changed, 35 insertions, 37 deletions
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 6374558ad..580145231 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -1027,6 +1027,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 (empty($property))
+ {
+ $property = strtolower($class);
+ isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
+ }
+
+ $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)
{
@@ -1037,27 +1057,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;
}
@@ -1102,16 +1103,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.');
@@ -1133,10 +1135,8 @@ class CI_Loader {
{
return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
}
- else
- {
- log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name);
- }
+
+ log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name);
}
}
@@ -1154,10 +1154,8 @@ class CI_Loader {
$prefix = config_item('subclass_prefix');
break;
}
- else
- {
- log_message('debug', $path.' exists, but does not declare '.$subclass);
- }
+
+ log_message('debug', $path.' exists, but does not declare '.$subclass);
}
}