Skip to content

Commit

Permalink
Fix #3694: Packages not overriding stock libraries
Browse files Browse the repository at this point in the history
Related: #3692
  • Loading branch information
narfbg committed Mar 25, 2015
1 parent 7ad5920 commit 8f5c178
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions system/core/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,34 +1079,47 @@ protected function _ci_load_stock_library($library_name, $file_path, $params, $o
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);
}
}
}

include_once(BASEPATH.'libraries/'.$file_path.$library_name.'.php');

// 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);
}
}
}

Expand Down

0 comments on commit 8f5c178

Please sign in to comment.