This commit is contained in:
Andrew Nicols 2022-12-13 11:38:06 +08:00
commit 3218a8feda
3 changed files with 17 additions and 2 deletions

View File

@ -3034,5 +3034,16 @@ privatefiles,moodle|/user/files.php';
// Automatically generated Moodle v4.1.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022120900.01) {
// Remove any orphaned role assignment records (pointing to non-existing roles).
$DB->delete_records_select('role_assignments', 'NOT EXISTS (
SELECT r.id FROM {role} r WHERE r.id = {role_assignments}.roleid
)');
// Main savepoint reached.
upgrade_main_savepoint(true, 2022120900.01);
}
return true;
}

View File

@ -1211,8 +1211,12 @@ function enrol_try_internal_enrol($courseid, $userid, $roleid = null, $timestart
if (!$instances = $DB->get_records('enrol', array('enrol'=>'manual', 'courseid'=>$courseid, 'status'=>ENROL_INSTANCE_ENABLED), 'sortorder,id ASC')) {
return false;
}
$instance = reset($instances);
if ($roleid && !$DB->record_exists('role', ['id' => $roleid])) {
return false;
}
$instance = reset($instances);
$enrol->enrol_user($instance, $userid, $roleid, $timestart, $timeend);
return true;

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022120900.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2022120900.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.2dev (Build: 20221209)'; // Human-friendly version name