MDL-64454 Admin: Configuration option for cron frequency warning

This change makes the warning time (default 200 seconds) configurable
in config.php.
This commit is contained in:
sam marshall 2019-01-08 12:14:57 +00:00
parent b18034ed67
commit ff13ae5906
4 changed files with 13 additions and 3 deletions

View file

@ -826,7 +826,8 @@ $errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
$lastcron = get_config('tool_task', 'lastcronstart');
$cronoverdue = ($lastcron < time() - 3600 * 24);
$lastcroninterval = get_config('tool_task', 'lastcroninterval');
$croninfrequent = !$cronoverdue && ($lastcroninterval > 200 || $lastcron < time() - 200);
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
$croninfrequent = !$cronoverdue && ($lastcroninterval > $expectedfrequency || $lastcron < time() - $expectedfrequency);
$dbproblems = $DB->diagnose();
$maintenancemode = !empty($CFG->maintenance_enabled);

View file

@ -623,11 +623,14 @@ class core_admin_renderer extends plugin_renderer_base {
* @return string HTML to output.
*/
public function cron_infrequent_warning(bool $croninfrequent) : string {
global $CFG;
if (!$croninfrequent) {
return '';
}
return $this->warning(get_string('croninfrequent', 'admin') . '&nbsp;' .
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
return $this->warning(get_string('croninfrequent', 'admin', $expectedfrequency) . '&nbsp;' .
$this->help_icon('cron', 'admin'));
}

View file

@ -599,6 +599,12 @@ $CFG->admin = 'admin';
//
// $CFG->disablelogintoken = true;
//
// Moodle 3.7+ checks that cron is running frequently. If the time between cron runs
// is greater than this value (in seconds), you get a warning on the admin page. (This
// setting only controls whether or not the warning appears, it has no other effect.)
//
// $CFG->expectedcronfrequency = 200;
//
//=========================================================================
// 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!
//=========================================================================

View file

@ -416,10 +416,10 @@ $string['cron_link'] = 'admin/cron';
$string['cronclionly'] = 'Cron execution via command line only';
$string['cronerrorclionly'] = 'Sorry, internet access to this page has been disabled by the administrator.';
$string['cronerrorpassword'] = 'Sorry, you have not provided a valid password to access this page';
$string['croninfrequent'] = 'The time between the last two runs of the cron maintenance script was over {$a} seconds. We recommend configuring it to run more frequently.';
$string['cronremotepassword'] = 'Cron password for remote access';
$string['cronwarning'] = 'The <a href="{$a}">cron.php maintenance script</a> has not been run for at least 24 hours.';
$string['cronwarningcli'] = 'The cli/cron.php maintenance script has not been run for at least 24 hours.';
$string['croninfrequent'] = 'The time between the last two runs of the cron maintenance script was over 3 minutes. We recommend configuring it to run more frequently.';
$string['ctyperequired'] = 'The ctype PHP extension is now required by Moodle, in order to improve site performance and to offer multilingual compatibility.';
$string['curlsecurityallowedport'] = 'cURL allowed ports list';
$string['curlsecurityallowedportsyntax'] = 'List of port numbers that cURL can connect to. Valid entries are integer numbers only. Put each entry on a new line. If left empty, then all ports are allowed. If set, in almost all cases, both 443 and 80 should be specified for cURL to connect to standard HTTPS and HTTP ports.';