New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-set config_item() cache #708
Comments
I think it is not static var probelm, you should following the config_item function
If you call "echo config_item('foo')" first, it run "$_config_item[$item] = $config[$item];"; It will return $_config_item[$item]; directly because the $_config_item array has the "foo" index value, if you run "config_item('foo')" twice. You can change the source code:
Thanks. |
Mate, you completely missed the point... :) |
What's situation you want to change? You can use set_item(key, value) and item(key) to resolve your problem. |
So, this one's an exact duplicate of issue #180. The use of a static var is intended to speed up things, but it does indeed make it hard to keep track of dynamic config changes. So, there are two options:
... I vote for the second one. |
As an OOP I personally would move the static var into "public Config::config", so Config::set_item() would be able to drop/update it. You can still reach Config::config from the helper. But I know this (sadly) is not the way stuff is done in CI... |
For reference, has been truly fixed in #2538 |
Hi,
when you change a config item during parse time, the config_item( ) would need to drop it's static "cache".
If you use this procedure:
in config.php:
$config['foo'] = 'bar';
in some controller:
echo config_item('foo'); # produces: bar $this->config->set_item('foo', 'baz'); echo config_item('foo'); # still produces: bar
The workaround is to use the direct Config method: $this->config->item('foo).
This should be fixed or at least noted in the documentation, that the common function config_item() uses a static var for caching purposes and can not be changed during parsetime (if the variable was already read and therefore cached one before).
The text was updated successfully, but these errors were encountered: