summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install58
1 files changed, 46 insertions, 12 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 03250d52c..3a53cde9e 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -89,25 +89,59 @@ function system_requirements($phase) {
$requirements['settings.php']['title'] = $t('Configuration file');
}
- // Report cron status
+ // Report cron status.
if ($phase == 'runtime') {
+ // Cron warning threshold defaults to two days.
+ $threshold_warning = variable_get('cron_threshold_warning', 172800);
+ // Cron error threshold defaults to two weeks.
+ $threshold_error = variable_get('cron_threshold_error', 1209600);
+ // Cron configuration help text.
+ $help = $t('Please check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron'));
+
+ // Determine when cron last ran. If never, use the install time to
+ // determine the warning or error status.
$cron_last = variable_get('cron_last', NULL);
+ $never_run = FALSE;
+ if (!is_numeric($cron_last)) {
+ $never_run = TRUE;
+ $cron_last = variable_get('install_time', 0);
+ }
- if (is_numeric($cron_last)) {
- $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last)));
+ // Determine severity based on time since cron last ran.
+ $severity = REQUIREMENT_OK;
+ if (time() - $cron_last > $threshold_error) {
+ $severity = REQUIREMENT_ERROR;
}
- else {
- $requirements['cron'] = array(
- 'description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')),
- 'severity' => REQUIREMENT_ERROR,
- 'value' => $t('Never run'),
- );
+ else if (time() - $cron_last > $threshold_warning) {
+ $severity = REQUIREMENT_WARNING;
}
- $requirements['cron'] += array('description' => '');
- $requirements['cron']['description'] .= ' '. $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
+ // If cron hasn't been run, and the user is viewing the main
+ // administration page, instead of an error, we display a helpful reminder
+ // to configure cron jobs.
+ if ($never_run && $severity != REQUIREMENT_ERROR && $_GET['q'] == 'admin') {
+ drupal_set_message($t('Cron has not run.') .' '. $help);
+ }
- $requirements['cron']['title'] = $t('Cron maintenance tasks');
+ // Set summary and description based on values determined above.
+ if ($never_run) {
+ $summary = $t('Never run');
+ $description = $t('Cron has not run.') .' '. $help;
+ }
+ else {
+ $summary = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last)));
+ $description = '';
+ if ($severity != REQUIREMENT_OK) {
+ $description = $t('Cron has not run recently.') .' '. $help;
+ }
+ }
+
+ $requirements['cron'] = array(
+ 'title' => $t('Cron maintenance tasks'),
+ 'severity' => $severity,
+ 'value' => $summary,
+ 'description' => $description .' '. $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron'))),
+ );
}
// Test files directory