Commit 55d17eec authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic

Bug 1733963: Remove users from groups if added after group deleted

This can happen if a group had auto add new members on yet the group
was deleted when the user was added to the site

behatnotneeded

Change-Id: I72de52032f41c21d961d437c48a6e87d4f299188
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent eee44112
......@@ -5717,5 +5717,18 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql("DELETE FROM {config} WHERE field = ?", array('alwaysallowselfdelete'));
}
if ($oldversion < 2018021601) {
log_debug('Remove auto-added users from deleted groups if added post deletion');
if ($records = get_records_sql_array("SELECT id, SUBSTR(name, POSITION('.deleted.' IN name) + LENGTH('.deleted.')) AS deltime
FROM {group} WHERE deleted = 1")) {
foreach ($records as $key => $record) {
if (is_numeric($record->deltime)) {
$timestamp = date('Y-m-d H:i:s', $record->deltime);
delete_records_sql('DELETE FROM {group_member} WHERE "group" = ? AND ctime >= ?', array($record->id, $timestamp));
}
}
}
}
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 = 2018021600;
$config->version = 2018021601;
$config->series = '18.04';
$config->release = '18.04dev';
$config->minupgradefrom = 2015030409;
......
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