summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-11-19 15:01:18 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-11-19 15:01:18 +0000
commite963f9d8817029da9477d975f74f17292d8cd4c2 (patch)
treed6d056655bd5d66973c6280466f239b483890387 /modules
parent04ca1b4676fa636138071da083f9159707d7328f (diff)
downloadbrdo-e963f9d8817029da9477d975f74f17292d8cd4c2.tar.gz
brdo-e963f9d8817029da9477d975f74f17292d8cd4c2.tar.bz2
#100909 by webernet and RobRoy: improve cron error reporting by defining time tresholds, so if cron stops running after some time, it also becomes an error, but cron not run yet is not an error on installation
Diffstat (limited to 'modules')
-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