Skip to content

Commit

Permalink
MDL-23361 fixed sloppy upgrade logic, sorry
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 18, 2010
1 parent 8682d4a commit 3db2ddb
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3040,19 +3040,18 @@ function xmldb_main_upgrade($oldversion) {
}

// add roles without archetypes, it may contain weird things, but we can not fix them
list($narsql, $params) = $DB->get_in_or_equal(array_keys($defaults), SQL_PARAMS_NAMED, 'ar000', false);
$sql = "SELECT DISTINCT ra.roleid, con.contextlevel
FROM {role_assignments} ra
JOIN {context} con ON ra.contextid = con.id";
$existingrolecontextlevels = $DB->get_recordset_sql($sql);
JOIN {context} con ON ra.contextid = con.id
JOIN {role} r ON r.id = ra.roleid
WHERE r.archetype $narsql";
$existingrolecontextlevels = $DB->get_recordset_sql($sql, $params);
foreach ($existingrolecontextlevels as $rcl) {
if (isset($roleids[$rcl->roleid])) {
continue;
}
if (!isset($rolecontextlevels[$rcl->roleid])) {
$rolecontextlevels[$rcl->roleid] = array($rcl->contextlevel);
} else if (!in_array($rcl->contextlevel, $rolecontextlevels[$rcl->roleid])) {
$rolecontextlevels[$rcl->roleid][] = $rcl->contextlevel;
$rolecontextlevels[$rcl->roleid] = array();
}
$rolecontextlevels[$rcl->roleid][] = $rcl->contextlevel;
}
$existingrolecontextlevels->close();

Expand Down

0 comments on commit 3db2ddb

Please sign in to comment.