MDL-64454 Admin: Warning if cron does not run frequently

There is an existing warning if cron doesn't run at all (hasn't run
for 24 hours). This commit adds a warning if cron hasn't run for 3
minutes, based on the recommendation that cron should run every
minute.
This commit is contained in:
sam marshall 2018-12-20 11:08:15 +00:00
parent 4c5b60a0f9
commit b18034ed67
4 changed files with 31 additions and 4 deletions

View file

@ -281,6 +281,7 @@ class core_admin_renderer extends plugin_renderer_base {
* @param bool $mobileconfigured Whether the mobile web services have been enabled
* @param bool $overridetossl Whether or not ssl is being forced.
* @param bool $invalidforgottenpasswordurl Whether the forgotten password URL does not link to a valid URL.
* @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
*
* @return string HTML to output.
*/
@ -288,7 +289,7 @@ class core_admin_renderer extends plugin_renderer_base {
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
$themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
$overridetossl = false, $invalidforgottenpasswordurl = false) {
$overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false) {
global $CFG;
$output = '';
@ -302,6 +303,7 @@ class core_admin_renderer extends plugin_renderer_base {
$output .= $this->display_errors_warning($errorsdisplayed);
$output .= $this->buggy_iconv_warning($buggyiconvnomb);
$output .= $this->cron_overdue_warning($cronoverdue);
$output .= $this->cron_infrequent_warning($croninfrequent);
$output .= $this->db_problems($dbproblems);
$output .= $this->maintenance_mode_warning($maintenancemode);
$output .= $this->overridetossl_warning($overridetossl);
@ -614,6 +616,21 @@ class core_admin_renderer extends plugin_renderer_base {
$this->help_icon('cron', 'admin'));
}
/**
* Render an appropriate message if cron is not being run frequently (recommended every minute).
*
* @param bool $croninfrequent
* @return string HTML to output.
*/
public function cron_infrequent_warning(bool $croninfrequent) : string {
if (!$croninfrequent) {
return '';
}
return $this->warning(get_string('croninfrequent', 'admin') . ' ' .
$this->help_icon('cron', 'admin'));
}
/**
* Render an appropriate message if there are any problems with the DB set-up.
* @param bool $dbproblems