Commit 2ffaa9a6 authored by heddn's avatar heddn Committed by heddn
Browse files

Issue #3058250 by heddn, catch: Cron frequency

parent ce362355
<?php
/**
* Cron frequency checker.
*/
class CronFrequency implements ReadinessCheckerInterface {
/**
* Minimum cron threshold is 3 hours.
*/
const MINIMUM_CRON_INTERVAL = 10800;
/**
* {@inheritdoc}
*/
public static function run() {
$messages = [];
if (variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD) > static::MINIMUM_CRON_INTERVAL) {
$messages[] = t('Cron is not set to run frequently enough. <a href="@configure">Configure it</a> to run at least every 3 hours or disable automated cron and run it via an external scheduling system.', [
'@configure' => url('admin/config/system/cron'),
]);
}
// Determine when cron last ran.
$cron_last = variable_get('cron_last');
if (!is_numeric($cron_last)) {
$cron_last = variable_get('install_time', 0);
}
if (REQUEST_TIME - $cron_last > static::MINIMUM_CRON_INTERVAL) {
$messages[] = t('Cron has not run recently. <a href="@configure">Configure it</a> to run at least every 3 hours or disable automated cron and run it via an external scheduling system.', [
'@configure' => url('admin/config/system/cron'),
]);
}
return $messages;
}
}
......@@ -23,6 +23,7 @@ class ReadinessCheckerManager {
*/
protected static function getCheckers() {
static::$checkers['warning'][0][] = 'BlacklistPhp72Versions';
static::$checkers['warning'][0][] = 'CronFrequency';
static::$checkers['warning'][0][] = 'FileOwnership';
static::$checkers['warning'][0][] = 'MissingProjectInfo';
static::$checkers['warning'][0][] = 'ModifiedFiles';
......
......@@ -11,6 +11,7 @@ files[] = ModifiedFilesService.php
files[] = ReadinessCheckers/ReadinessCheckerManager.php
files[] = ReadinessCheckers/ReadinessCheckerInterface.php
files[] = ReadinessCheckers/BlacklistPhp72Versions.php
files[] = ReadinessCheckers/CronFrequency.php
files[] = ReadinessCheckers/DiskSpace.php
files[] = ReadinessCheckers/FileOwnership.php
files[] = ReadinessCheckers/MissingProjectInfo.php
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment