diff options
author | vlakoff <vlakoff@gmail.com> | 2013-07-19 02:06:41 +0200 |
---|---|---|
committer | vlakoff <vlakoff@gmail.com> | 2013-07-19 02:06:41 +0200 |
commit | af431ce8e9f7759e938b6535bde68ade3cd1caa8 (patch) | |
tree | e9554f99baf8d5e51ef3dfc623430b2aecfcada2 /system/core/Common.php | |
parent | f46b16b096fd4861486138b604a29ba19c0cda88 (diff) |
Fix config_item() returning stale values
Use case fixed:
config_item('foobar'); // returns "some value"
$CI->config->set_item('foobar', 'new value');
config_item('foobar'); // still returns "some value", expected "new value"
Diffstat (limited to 'system/core/Common.php')
-rw-r--r-- | system/core/Common.php | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/system/core/Common.php b/system/core/Common.php index 93cd0a0ae..b95a05db9 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -289,20 +289,15 @@ if ( ! function_exists('config_item')) */ function config_item($item) { - static $_config_item = array(); + static $_config; - if ( ! isset($_config_item[$item])) + if (empty($_config)) { - $config =& get_config(); - - if ( ! isset($config[$item])) - { - return FALSE; - } - $_config_item[$item] = $config[$item]; + // references cannot be directly assigned to static variables, so we use an array + $_config[0] =& get_config(); } - return $_config_item[$item]; + return isset($_config[0][$item]) ? $_config[0][$item] : FALSE; } } |