function _security_review_run_check in Security Review 6
Same name and namespace in other branches
- 7 security_review.inc \_security_review_run_check()
 
Run a single Security Review check.
2 calls to _security_review_run_check()
- _security_review_batch_op in ./
security_review.module  - Operation function called by Batch.
 - _security_review_run in ./
security_review.inc  - Private function run review and returns the full results.
 
File
- ./
security_review.inc, line 62  - Stand-alone security checks and review system.
 
Code
function _security_review_run_check($module, $check_name, $check, $log, $store = FALSE) {
  $last_check = array();
  if ($store) {
    // Get the results of the last check.
    $last_check = security_review_get_last_check($module, $check_name);
  }
  $check_result = array();
  $return = array(
    'result' => NULL,
  );
  if (isset($check['file'])) {
    // Handle Security Review defining checks for other modules.
    if (isset($check['module'])) {
      $module = $check['module'];
    }
    module_load_include('inc', $module, $check['file']);
  }
  $function = $check['callback'];
  if (function_exists($function)) {
    $return = call_user_func($function, $last_check);
  }
  $check_result = array_merge($check, $return);
  $check_result['lastrun'] = time();
  if ($log && !is_null($return['result'])) {
    // Do not log if result is NULL.
    $variables = array(
      '!name' => $check_result['title'],
    );
    if ($check_result['result']) {
      _security_review_log($module, $check_name, '!name check passed', $variables, WATCHDOG_INFO);
    }
    else {
      _security_review_log($module, $check_name, '!name check failed', $variables, WATCHDOG_ERROR);
    }
  }
  return $check_result;
}