-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Add new method to get config value directly from DB bypassing cache. #4163
Conversation
UnitTest requires a DB ... added in #4138 |
It's up to you, but in my opinion, this is a pattern that should never be used since the config cache should only be updated by users or on deployment. I usually use core/flag instead, very convenient and fast and no need to touch cache. Just a thought. |
Core config is not the right place for frequently changing values, but its "common" practice. Having a method to bypass cache is a +1. I think most dont know about core/flag .... maybe worth a write-up? |
I am aware of Some errors can only be captured with // index.php, before Mage::run($mageRunCode, $mageRunType);
register_shutdown_function(function(){
$err = error_get_last();
if ($err && $err['type'] != E_WARNING) {
$err['type'] = $err['type'] . ':' . array_search($err['type'], get_defined_constants(true)['Core']);
$err['uri'] = $_SERVER['REQUEST_URI'] ?? $_SERVER['SCRIPT_NAME'];
[$err['user'], $err['role']] = Mage::helper('base')->getSessionUser();
Mage::getModel('core/flag', ['flag_code' => 'error_get_last'])
->loadSelf()
->setFlagData($err)
->save();
}
}); And get the last error: $flag = Mage::getModel('core/flag', ['flag_code' => 'error_get_last'])->loadSelf(); But in my use case, the admin users need to view and edit the value. So I can't use |
I think there plenty of real use-cases for this ... e.g update/(re-)set a timestamp from backend, Set a value thats used in a cron-job ... IMHO theres nothing wrong to provide this posibility. |
Description (*)
We can save a config value by
However, if cache is enabled, after saving
$newValue
, the following will return the old value:To get the new value, we need to refresh the cache with
Mage::getConfig()->reinit();
.In my use case, I needed to get and update config value in a cron running constantly. It's not good idea to keep refreshing cache. (Also, I need to allow admin users to edit the value in the System Configuration. It turns out that values here are updated and not from the cache.)
With this PR, we can get the current value by
Fixed Issues (if relevant)
Over the years, others need similar feature, see stackoverflow
Manual testing scenarios (*)