Commit cdc7c949 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1648927: Set deleted institution's groups correctly



Currently set the group shortname/institution to NULL but now we
should leave shortname alone and change institution = 'mahara'

behatnotneeded

Change-Id: I390d5e8e17c3edca40a59438e5160db00fcc60fb
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 8c982568
......@@ -154,7 +154,7 @@ if ($institution || $add) {
execute_sql('DELETE FROM {favorite_usr} WHERE favorite IN (SELECT id FROM {favorite} WHERE institution = ?)', array($values['i']));
delete_records('favorite', 'institution', $values['i']);
execute_sql("UPDATE {group} SET institution = NULL, shortname = NULL WHERE institution = ?", array($values['i']));
execute_sql("UPDATE {group} SET institution = 'mahara' WHERE institution = ?", array($values['i']));
delete_records('auth_instance', 'institution', $values['i']);
delete_records('host', 'institution', $values['i']);
delete_records('institution_locked_profile_field', 'name', $values['i']);
......
......@@ -4833,5 +4833,28 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
// Need to run these two group updates again because we didn't notice
// deleting an institution causes group shortnames to be deleted
if ($oldversion < 2016122300) {
require_once(get_config('docroot') . 'lib/group.php');
log_debug('Assign a unique shortname for each existing group that doesn\'t have one.');
$groups = get_records_select_array(
'group',
"(shortname IS NULL OR shortname = '') AND deleted = 0"
);
if (!empty($groups)) {
foreach ($groups as $group) {
$group->shortname = group_generate_shortname($group->name);
update_record('group', $group, 'id');
}
}
log_debug('Assign an istitution for each existing group that doesn\'t have one.');
$groups = execute_sql("UPDATE {group} SET institution = 'mahara'
WHERE (institution IS NULL OR institution = '') AND deleted = 0", array());
}
return $status;
}
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2016112400;
$config->version = 2016122300;
$config->series = '17.04';
$config->release = '17.04dev';
$config->minupgradefrom = 2012080604;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment