diff options
author | Andrey Andreev <narf@devilix.net> | 2013-08-19 18:54:49 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2013-08-19 18:54:49 +0200 |
commit | 1bd299182fa20ee7b94805e7f27affcf9a166d92 (patch) | |
tree | d4aff237cccea8eb8432873d2c35f9398f742267 /system | |
parent | e19b5557e8c2c074db0c1c104c26a7b23d9d9b6f (diff) | |
parent | 05d043b38896570004fadbed8495fc99c6ef3da6 (diff) |
Merge pull request #2609 from vlakoff/develop-2
Fix $replace parameter handling in get_config()
Diffstat (limited to 'system')
-rw-r--r-- | system/core/CodeIgniter.php | 2 | ||||
-rw-r--r-- | system/core/Common.php | 73 |
2 files changed, 35 insertions, 40 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index a026920a4..c962fda20 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -88,7 +88,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * The subclass prefix allows CI to know if a core class is * being extended via a library in the local application * "libraries" folder. Since CI allows config items to be - * overriden via data set in the main index. php file, + * overriden via data set in the main index.php file, * before proceeding we need to know if a subclass_prefix * override exists. If so, we will set this value now, * before any classes are loaded diff --git a/system/core/Common.php b/system/core/Common.php index 21e1df9c6..cf9cd846d 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -224,56 +224,51 @@ if ( ! function_exists('get_config')) * @param array * @return array */ - function &get_config($replace = array()) + function &get_config(array $replace = array()) { static $_config; - if (isset($_config)) + if (empty($_config)) { - return $_config[0]; - } + $file_path = APPPATH.'config/config.php'; + $found = FALSE; + if (file_exists($file_path)) + { + $found = TRUE; + require($file_path); + } - $file_path = APPPATH.'config/config.php'; - $found = FALSE; - if (file_exists($file_path)) - { - $found = TRUE; - require($file_path); - } + // Is the config file in the environment folder? + if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + { + require($file_path); + } + elseif ( ! $found) + { + set_status_header(503); + echo 'The configuration file does not exist.'; + exit(EXIT_CONFIG); + } - // Is the config file in the environment folder? - if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) - { - require($file_path); - } - elseif ( ! $found) - { - set_status_header(503); - echo 'The configuration file does not exist.'; - exit(EXIT_CONFIG); - } + // Does the $config array exist in the file? + if ( ! isset($config) OR ! is_array($config)) + { + set_status_header(503); + echo 'Your config file does not appear to be formatted correctly.'; + exit(EXIT_CONFIG); + } - // Does the $config array exist in the file? - if ( ! isset($config) OR ! is_array($config)) - { - set_status_header(503); - echo 'Your config file does not appear to be formatted correctly.'; - exit(EXIT_CONFIG); + // references cannot be directly assigned to static variables, so we use an array + $_config[0] =& $config; } - // Are any values being dynamically replaced? - if (count($replace) > 0) + // Are any values being dynamically added or replaced? + foreach ($replace as $key => $val) { - foreach ($replace as $key => $val) - { - if (isset($config[$key])) - { - $config[$key] = $val; - } - } + $_config[0][$key] = $val; } - return $_config[0] =& $config; + return $_config[0]; } } @@ -441,7 +436,7 @@ if ( ! function_exists('log_message')) { static $_log; - if ($_log === NULL) + if (empty($_log)) { // references cannot be directly assigned to static variables, so we use an array $_log[0] =& load_class('Log', 'core'); |