WatchdogAge.php in Site Audit 8.3
File
src/Plugin/SiteAuditCheck/WatchdogAge.php
View source
<?php
namespace Drupal\site_audit\Plugin\SiteAuditCheck;
use Drupal\site_audit\Plugin\SiteAuditCheckBase;
class WatchdogAge extends SiteAuditCheckBase {
public $ageNewest;
public $ageOldest;
public function getResultFail() {
}
public function getResultInfo() {
if (date('Y-m-d', $this->ageOldest) != date('Y-m-d', $this->ageNewest)) {
return $this
->t('From @from to @to (@days days)', [
'@from' => date('r', $this->ageOldest),
'@to' => date('r', $this->ageNewest),
'@days' => round(($this->ageNewest - $this->ageOldest) / 86400, 2),
]);
}
return $this
->t('From @from to @to', [
'@from' => date('r', $this->ageOldest),
'@to' => date('r', $this->ageNewest),
]);
}
public function getResultPass() {
}
public function getResultWarn() {
}
public function getAction() {
}
public function calculateScore() {
$query = \Drupal::database()
->select('watchdog');
$query
->addField('watchdog', 'timestamp');
$query
->orderBy('wid', 'ASC');
$query
->range(0, 1);
$this->ageOldest = $query
->execute()
->fetchField();
$query = \Drupal::database()
->select('watchdog');
$query
->addField('watchdog', 'timestamp');
$query
->orderBy('wid', 'DESC');
$query
->range(0, 1);
$this->ageNewest = $query
->execute()
->fetchField();
return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
}
}