Skip to content

Commit

Permalink
Merge branch 'MDL-76536-400' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
andrewnicols committed Dec 13, 2022
2 parents 4ab2e98 + 93ac861 commit 8a4a9fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -4558,5 +4558,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2022041904.14);
}

if ($oldversion < 2022041905.07) {

// 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, 2022041905.07);
}

return true;
}
6 changes: 5 additions & 1 deletion lib/enrollib.php
Expand Up @@ -1196,8 +1196,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;
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2022041905.06; // 20220419 = branching date YYYYMMDD - do not modify!
$version = 2022041905.07; // 20220419 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0.5+ (Build: 20221209)'; // Human-friendly version name
Expand Down

0 comments on commit 8a4a9fc

Please sign in to comment.