public function SiteAuditCheckCronEnabled::calculateScore in Site Audit 8.2
Same name and namespace in other branches
- 7 Check/Cron/Enabled.php \SiteAuditCheckCronEnabled::calculateScore()
Implements \SiteAudit\Check\Abstract\calculateScore().
Overrides SiteAuditCheckAbstract::calculateScore
File
- Check/
Cron/ Enabled.php, line 82 - Contains \SiteAudit\Check\Cron\Enabled.
Class
- SiteAuditCheckCronEnabled
- Class SiteAuditCheckCronEnabled.
Code
public function calculateScore() {
// Determine when cron last ran.
$this->registry['cron_last'] = \Drupal::state()
->get('system.cron_last');
$this->registry['cron_safe_threshold'] = \Drupal::config('system.cron')
->get('threshold.autorun');
// Cron hasn't run in the past day.
if (time() - $this->registry['cron_last'] > 24 * 60 * 60) {
if ($this->registry['cron_safe_threshold'] === 0) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
}
else {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
}
elseif ($this->registry['cron_safe_threshold'] > 24 * 60 * 60) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}