Upstream Patch: Override path patch
This commit is contained in:
@@ -191,6 +191,7 @@ class Kohana_Core {
|
||||
|
||||
// Kohana is now initialized
|
||||
Kohana::$_init = TRUE;
|
||||
Kohana::$_paths = Kohana::build_paths();
|
||||
|
||||
if (isset($settings['profile']))
|
||||
{
|
||||
@@ -370,7 +371,7 @@ class Kohana_Core {
|
||||
|
||||
// Reset internal storage
|
||||
Kohana::$_modules = Kohana::$_files = array();
|
||||
Kohana::$_paths = array(APPPATH, SYSPATH);
|
||||
Kohana::$_paths = Kohana::build_paths();
|
||||
|
||||
// Reset file cache status
|
||||
Kohana::$_files_changed = FALSE;
|
||||
@@ -511,14 +512,15 @@ class Kohana_Core {
|
||||
}
|
||||
|
||||
// Start a new list of include paths, APPPATH first
|
||||
$paths = array(APPPATH);
|
||||
$paths = array();
|
||||
|
||||
foreach ($modules as $name => $path)
|
||||
{
|
||||
if (is_dir($path))
|
||||
{
|
||||
// Add the module to include paths
|
||||
$paths[] = $modules[$name] = realpath($path).DIRECTORY_SEPARATOR;
|
||||
$modules[$name] = realpath($path).DIRECTORY_SEPARATOR;
|
||||
$paths[] = $name;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -527,11 +529,8 @@ class Kohana_Core {
|
||||
}
|
||||
}
|
||||
|
||||
// Finish the include paths by adding SYSPATH
|
||||
$paths[] = SYSPATH;
|
||||
|
||||
// Set the new include paths
|
||||
Kohana::$_paths = $paths;
|
||||
Kohana::$_paths = Kohana::build_paths($paths);
|
||||
|
||||
// Set the current module list
|
||||
Kohana::$_modules = $modules;
|
||||
@@ -550,6 +549,39 @@ class Kohana_Core {
|
||||
return Kohana::$_modules;
|
||||
}
|
||||
|
||||
public static function build_paths(array $module_paths=array()) {
|
||||
// Start a new list of include paths, APPPATH first
|
||||
$paths = array();
|
||||
|
||||
if (OVERPATH AND is_dir(OVERPATH.'application'))
|
||||
$paths[] = OVERPATH.'application';
|
||||
|
||||
$paths[] = APPPATH;
|
||||
|
||||
// Add our modules
|
||||
foreach ($module_paths as $path)
|
||||
{
|
||||
if (is_dir(MODPATH.$path))
|
||||
{
|
||||
// Add the override path
|
||||
if (OVERPATH AND is_dir(OVERPATH.'modules'.DIRECTORY_SEPARATOR.$path))
|
||||
{
|
||||
$paths[] = realpath(OVERPATH.'modules'.DIRECTORY_SEPARATOR.$path).DIRECTORY_SEPARATOR;
|
||||
}
|
||||
// Add the module to include paths
|
||||
$paths[] = realpath(MODPATH.$path).DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
|
||||
// Finish the include paths by adding SYSPATH
|
||||
if (OVERPATH AND is_dir(OVERPATH.'system'))
|
||||
$paths[] = OVERPATH.'system';
|
||||
|
||||
$paths[] = SYSPATH;
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the the currently active include paths, including the
|
||||
* application and system paths.
|
||||
@@ -1355,6 +1387,10 @@ class Kohana_Core {
|
||||
{
|
||||
$file = 'MODPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(MODPATH));
|
||||
}
|
||||
elseif (strpos($file, OVERPATH) === 0)
|
||||
{
|
||||
$file = 'OVERPATH/'.substr($file, strlen(OVERPATH));
|
||||
}
|
||||
elseif (strpos($file, DOCROOT) === 0)
|
||||
{
|
||||
$file = 'DOCROOT'.DIRECTORY_SEPARATOR.substr($file, strlen(DOCROOT));
|
||||
|
Reference in New Issue
Block a user