You are here

public function SiteAuditCheckWatchdogPhp::calculateScore in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Watchdog/Php.php \SiteAuditCheckWatchdogPhp::calculateScore()

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Watchdog/Php.php, line 70
Contains \SiteAudit\Check\Watchdog\Php.

Class

SiteAuditCheckWatchdogPhp
Class SiteAuditCheckWatchdogPhp.

Code

public function calculateScore() {
  $this->registry['php_counts'] = array();
  $this->registry['php_count_total'] = 0;
  $this->registry['percent_php'] = 0;
  $types = drush_watchdog_message_types();
  if (array_search('php', $types) === FALSE) {
    $this->abort = TRUE;
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
  }
  $where = core_watchdog_query('php', NULL, NULL);
  $rsc = drush_db_select('watchdog', '*', $where['where'], $where['args'], 0, NULL, 'wid', 'DESC');
  while ($result = drush_db_fetch_object($rsc)) {
    $row = core_watchdog_format_result($result);
    if (!isset($this->registry['php_counts'][$row->severity])) {
      $this->registry['php_counts'][$row->severity] = 0;
    }
    $this->registry['php_counts'][$row->severity]++;
    $this->registry['php_count_total']++;
  }
  $this->registry['percent_php'] = round($this->registry['php_count_total'] / $this->registry['count_entries'] * 100, 2);
  if ($this->registry['percent_php'] >= 10) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}