diff --git a/mollom.module b/mollom.module index 05eb729..6871630 100644 --- a/mollom.module +++ b/mollom.module @@ -1407,36 +1407,51 @@ function _mollom_status($reset = FALSE) { // If we have keys and are asked to reset, check whether keys are valid. if ($status['keys'] && $reset) { - $status['keys valid'] = $mollom->verifyKeys(); - if ($status['keys valid'] === TRUE) { - mollom_log(array( - 'message' => 'API keys are valid.', - ), WATCHDOG_INFO); - } - elseif ($status['keys valid'] === Mollom::REQUEST_ERROR) { - mollom_log(array( - 'message' => 'Invalid client configuration.', - ), WATCHDOG_ERROR); - } - elseif ($status['keys valid'] === Mollom::AUTH_ERROR) { - mollom_log(array( - 'message' => 'Invalid API keys.', - ), WATCHDOG_ERROR); - } - // If the response is neither positive nor a known negative error, and - // the previous status was positive, then the Mollom service might be - // temporarily down. In this case, return an enforced RESPONSE_ERROR to - // indicate a server-side service failure, but do not update the stored - // status. - // @todo Test this. - elseif ($current_status['keys valid'] === TRUE) { - $status['keys valid'] = Mollom::RESPONSE_ERROR; - // Do not update the stored configuration status with the bogus result - // caused by the server-side failure. - $reset = FALSE; - mollom_log(array( - 'message' => 'API keys could not be verified.', - ), WATCHDOG_WARNING); + if (!lock_acquire('mollom_status', 5)) { + lock_wait('mollom_status'); + // variable_initialize() cannot be safely called again, so retrieve the + // value directly from the database. + $db_status = db_query('SELECT value FROM {variable} WHERE name = :name', array( + ':name' => 'mollom_status', + ))->fetchField(); + if ($db_status) { + $status = unserialize($db_status); + } + } + else { + $status['keys valid'] = $mollom->verifyKeys(); + if ($status['keys valid'] === TRUE) { + mollom_log(array( + 'message' => 'API keys are valid.', + ), WATCHDOG_INFO); + } + elseif ($status['keys valid'] === Mollom::REQUEST_ERROR) { + mollom_log(array( + 'message' => 'Invalid client configuration.', + ), WATCHDOG_ERROR); + } + elseif ($status['keys valid'] === Mollom::AUTH_ERROR) { + mollom_log(array( + 'message' => 'Invalid API keys.', + ), WATCHDOG_ERROR); + } + // If the response is neither positive nor a known negative error, and + // the previous status was positive, then the Mollom service might be + // temporarily down. In this case, return an enforced RESPONSE_ERROR to + // indicate a server-side service failure, but do not update the stored + // status. + // @todo Test this. + elseif ($current_status['keys valid'] === TRUE) { + $status['keys valid'] = Mollom::RESPONSE_ERROR; + // Do not update the stored configuration status with the bogus result + // caused by the server-side failure. + $reset = FALSE; + mollom_log(array( + 'message' => 'API keys could not be verified.', + ), WATCHDOG_WARNING); + } + + lock_release('mollom_status'); } } // Otherwise, if there are no keys, they cannot be valid.