diff options
-rw-r--r-- | install.php | 3 | ||||
-rw-r--r-- | modules/system/system.install | 58 |
2 files changed, 49 insertions, 12 deletions
diff --git a/install.php b/install.php index 69e703881..2706527b7 100644 --- a/install.php +++ b/install.php @@ -1073,6 +1073,9 @@ function install_configure_form_submit($form, &$form_state) { // The user is now logged in, but has no session ID yet, which // would be required later in the request, so remember it. $user->sid = session_id(); + + // Record when this install ran. + variable_set('install_time', time()); } // Start the installer. 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 |