public function Watchdog404::calculateScore in Site Audit 8.3
.
Overrides SiteAuditCheckBase::calculateScore
File
- src/
Plugin/ SiteAuditCheck/ Watchdog404.php, line 60
Class
- Watchdog404
- Provides the Watchdog404 Check.
Namespace
Drupal\site_audit\Plugin\SiteAuditCheckCode
public function calculateScore() {
if (empty($this->registry->count_entries)) {
$this
->checkInvokeCalculateScore('watchdog_count');
}
if (!$this->registry->watchdog_enabled) {
return;
}
$query = \Drupal::database()
->select('watchdog');
$query
->addExpression('COUNT(wid)', 'count');
$query
->condition('type', 'page not found');
$this->registry->count_404 = $query
->execute()
->fetchField();
$this->registry->percent_404 = 0;
// @TODO: Aggregate 404 entries and return top 10.
if (!$this->registry->count_404) {
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_PASS;
}
$this->registry->percent_404 = round($this->registry->count_404 / $this->registry->count_entries * 100);
if ($this->registry->percent_404 >= 10) {
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_WARN;
}
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
}