MDL-59986 enrol: database sync as scheduled task

This commit is contained in:
Daniel Neis Araujo 2018-08-21 15:17:49 -03:00
parent c092f75791
commit d6f7480d02
6 changed files with 116 additions and 2 deletions

View file

@ -26,6 +26,8 @@
* - you need to change the "www-data" to match the apache user account
* - use "su" if "sudo" not available
*
* @deprecated since Moodle 3.7 MDL-59986 - please do not use this CLI script any more, use scheduled task instead.
* @todo MDL-63266 This will be deleted in Moodle 4.1.
* @package enrol_database
* @copyright 2010 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@ -65,6 +67,14 @@ Sample cron entry:
die;
}
cli_problem('[ENROL DATABASE] The sync enrolments cron script has been deprecated. Please use the scheduled task instead.');
// Abort execution of the CLI script if the enrol_database\task\sync_enrolments is enabled.
$task = \core\task\manager::get_scheduled_task('enrol_database\task\sync_enrolments');
if (!$task->get_disabled()) {
cli_error('[ENROL DATABASE] The scheduled task sync_enrolments is enabled, the cron execution has been aborted.');
}
if (!enrol_is_enabled('database')) {
cli_error('enrol_database plugin is disabled, synchronisation stopped', 2);
}