Skip to content
Browse files

Removed support for driver extensions in libraries dir and fixed sess…

…ion unit test

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
1 parent 5af440d commit b1ddeb06836d55fdce7df2ee74a7210ba1dc5039 @dchill42 committed Nov 24, 2012
Showing with 12 additions and 23 deletions.
  1. +11 −22 system/core/Loader.php
  2. +1 −1 tests/codeigniter/libraries/Session_test.php
View
33 system/core/Loader.php
@@ -968,6 +968,9 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
}
}
+ // Get the subclass prefix
+ $prefix = config_item('subclass_prefix');
+
// We'll test for both lowercase and capitalized versions of the file name
$cases = array(ucfirst($class));
if (DIRECTORY_SEPARATOR !== '\\')
@@ -981,35 +984,21 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
foreach($trysubs as $dir)
{
// Check each path for an extension file
- $subclass = APPPATH.'libraries/'.$dir.config_item('subclass_prefix').$class.'.php';
+ $subclass = APPPATH.'libraries/'.$dir.$prefix.$class.'.php';
if (file_exists($subclass))
{
- // Found it - check paths for the base
- // 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 $basesub)
- {
- $baseclass = BASEPATH.'libraries/'.$basesub.ucfirst($class).'.php';
- if (file_exists($baseclass))
- {
- $found = TRUE;
- break;
- }
- }
-
- if ( ! $found)
- {
+ // Require the base class in the same directory
+ $baseclass = BASEPATH.'libraries/'.$dir.ucfirst($class).'.php';
+ if ( ! file_exists($baseclass))
+ {
// No base matches extension - bail
$msg = 'Unable to load the requested class: '.$class;
log_message('error', $msg);
show_error($msg);
}
// Does this look like a driver?
- $driversub = strtolower($class).'/';
- if ((strtolower($dir) === $driversub OR strtolower($basesub) === $driversub)
- && ! class_exists('CI_Driver_Library'))
+ 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';
@@ -1026,7 +1015,7 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ return $this->_ci_init_class($class, $prefix, $params, $object_name);
}
}
@@ -1039,7 +1028,7 @@ protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
include($subclass);
$this->_ci_loaded_files[] = $subclass;
- return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
+ return $this->_ci_init_class($class, $prefix, $params, $object_name);
}
}
View
2 tests/codeigniter/libraries/Session_test.php
@@ -40,7 +40,7 @@ public function set_up()
$this->ci_vfs_clone('system/helpers/string_helper.php');
// Set subclass prefix to match our mock
- $obj->config->set_item('subclass_prefix', 'Mock_Libraries_');
+ $ci->config->set_item('subclass_prefix', 'Mock_Libraries_');
// Attach session instance locally
$config = array(

0 comments on commit b1ddeb0

Please sign in to comment.
Something went wrong with that request. Please try again.