Permalink
Browse files

Tweaked Driver base autoload and switched include_once to include

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
dchill42 committed Sep 12, 2012
1 parent b9981f6 commit 1db3e0e34b057c008220a37da5101b569fb3bef2
Showing with 21 additions and 12 deletions.
  1. +21 −12 system/core/Loader.php
View
@@ -909,13 +909,6 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
// Get the filename from the path
$class = substr($class, $last_slash);
-
- // Check for match and driver base class
- if (strtolower(trim($subdir, '/')) == strtolower($class) && ! class_exists('CI_Driver_Library'))
- {
- // We aren't instantiating an object here, just making the base class available
- require BASEPATH.'libraries/Driver.php';
- }
}
// Establish subdirectories to try - if one was specified, just use that
@@ -942,9 +935,9 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
// The second loop here allows us to match an extension in
// the libraries root with a base in a subdirectory (like a driver!)
$found = FALSE;
- foreach ($trysubs as $dir)
+ foreach ($trysubs as $basesub)
{
- $baseclass = BASEPATH.'libraries/'.$dir.ucfirst($class).'.php';
+ $baseclass = BASEPATH.'libraries/'.$basesub.ucfirst($class).'.php';
if (file_exists($baseclass))
{
$found = TRUE;
@@ -960,6 +953,15 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
show_error($msg);
}
+ // Does this look like a driver?
+ $driversub = strtolower($class).'/';
+ if ((strtolower($dir) == $driversub || strtolower($basesub) == $driversub)
+ && ! class_exists('CI_Driver_Library'))
+ {
+ // We aren't instantiating an object here, just making the base class available
+ require BASEPATH.'libraries/Driver.php';
+ }
+
// Safety: Was the class already loaded by a previous call?
if (in_array($subclass, $this->_ci_loaded_files))
{
@@ -981,8 +983,8 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
return;
}
- include_once($baseclass);
- include_once($subclass);
+ include($baseclass);
+ include($subclass);
$this->_ci_loaded_files[] = $subclass;
return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
@@ -1003,6 +1005,13 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
continue;
}
+ // Does this look like a driver?
+ if (strtolower($dir) == strtolower($class).'/' && ! class_exists('CI_Driver_Library'))
+ {
+ // We aren't instantiating an object here, just making the base class available
+ require BASEPATH.'libraries/Driver.php';
+ }
+
// Safety: Was the class already loaded by a previous call?
if (in_array($filepath, $this->_ci_loaded_files))
{
@@ -1023,7 +1032,7 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
return;
}
- include_once($filepath);
+ include($filepath);
$this->_ci_loaded_files[] = $filepath;
return $this->_ci_init_class($class, '', $params, $object_name);
}

0 comments on commit 1db3e0e

Please sign in to comment.