Merge branch 'MDL-76536-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE

This commit is contained in:
Andrew Nicols 2022-12-13 11:42:35 +08:00
commit 0d5d3a0c49
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 < 2022112800.03) {
// 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, 2022112800.03);
}
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 = 2022112800.02; // 20221128 = branching date YYYYMMDD - do not modify!
$version = 2022112800.03; // 20221128 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.1+ (Build: 20221209)'; // Human-friendly version name