summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Common.php17
-rw-r--r--system/core/Config.php22
-rw-r--r--system/core/Loader.php15
3 files changed, 39 insertions, 15 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index b5adfacb3..cd6b93355 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -208,15 +208,20 @@
return $_config[0];
}
+ $file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT;
+
// Fetch the config file
- if ( ! file_exists(APPPATH.'config/config'.EXT))
- {
- exit('The configuration file does not exist.');
- }
- else
+ if ( ! file_exists($file_path))
{
- require(APPPATH.'config/config'.EXT);
+ $file_path = APPPATH.'config/config'.EXT;
+
+ if ( ! file_exists($file_path))
+ {
+ exit('The configuration file does not exist.');
+ }
}
+
+ require($file_path);
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
diff --git a/system/core/Config.php b/system/core/Config.php
index bfb60fa44..da22222dc 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -74,6 +74,8 @@ class CI_Config {
*
* @access public
* @param string the config file name
+ * @param boolean if configuration values should be loaded into their own section
+ * @param boolean true if errors should just return false, false if an error message should be displayed
* @return boolean if the file was loaded correctly
*/
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
@@ -82,8 +84,8 @@ class CI_Config {
$loaded = FALSE;
foreach($this->_config_paths as $path)
- {
- $file_path = $path.'config/'.$file.EXT;
+ {
+ $file_path = $path.'config/'.ENVIRONMENT.'/'.$file.EXT;
if (in_array($file_path, $this->is_loaded, TRUE))
{
@@ -91,11 +93,17 @@ class CI_Config {
continue;
}
- if ( ! file_exists($path.'config/'.$file.EXT))
+ if ( ! file_exists($file_path))
{
- continue;
+ log_message('debug', 'Config for '.ENVIRONMENT.' environment is not found. Trying global config.');
+ $file_path = $path.'config/'.$file.EXT;
+
+ if ( ! file_exists($file_path))
+ {
+ continue;
+ }
}
-
+
include($file_path);
if ( ! isset($config) OR ! is_array($config))
@@ -136,9 +144,9 @@ class CI_Config {
{
return FALSE;
}
- show_error('The configuration file '.$file.EXT.' does not exist.');
+ show_error('The configuration file '.ENVIRONMENT.'/'.$file.EXT.' and '.$file.EXT.' do not exist.');
}
-
+
return TRUE;
}
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 07166188e..ca2f016e7 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -880,8 +880,19 @@ class CI_Loader {
foreach ($config_component->_config_paths as $path)
{
// We test for both uppercase and lowercase, for servers that
- // are case-sensitive with regard to file names
- if (file_exists($path .'config/'.strtolower($class).EXT))
+ // are case-sensitive with regard to file names. Check for environment
+ // first, global next
+ if (file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.strtolower($class).EXT))
{
include_once($path .'config/'.strtolower($class).EXT);
break;