Hi there, thanks for this great module.
While debugging a performance problem for a client, I've come across this bit of code that looked strange to me:
if ($phase == 'runtime') {
$correct_key = variable_set('smart_ip_correct_ipinfodb_key', FALSE);
if (!$correct_key) {
$smart_ip_source = variable_get('smart_ip_source', 'ipinfodb_service');
if ($smart_ip_source == 'ipinfodb_service') {
// Generate an appropriate error message:
// Missing API keys.
.......
.......
The logic within the whole block seems correct, but the problem is that variable_set() is incorrectly called at the beginning of it. It should be variable_get() instead:
$correct_key = variable_get('smart_ip_correct_ipinfodb_key', FALSE);
Otherwise, 2 things happen:
1.- a cache_clear_all is triggered for the variables in cache_bootstrap (as part of the variable_set() call).
2.- The logic of the conditional is always triggered because $correct_key evaluates always to FALSE (), since variable_set() returns nothing.
I'm attaching a patch for the Drupal 7 version of this. I'm not sure, but I think the problem exists for Drupal 8 too.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2890397-incorrect_variable_set-2.patch | 2.09 KB | slv_ |
Comments
Comment #2
slv_ CreditAttribution: slv_ at Bluespark commentedPatch attached. It fixes a couple of spacing issues too.
Comment #3
slv_ CreditAttribution: slv_ at Bluespark commentedComment #6
arpeggio CreditAttribution: arpeggio as a volunteer commentedHi, I have already pushed your patch. Thank you for sharing it.