mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-29350 Prevent duplication of groupings when copying activities
This patch also includes a database upgrade to correct data produced as a result of this bug.
This commit is contained in:
parent
6be90ce05f
commit
6336bd914a
3 changed files with 24 additions and 2 deletions
|
@ -6916,6 +6916,21 @@ FROM
|
|||
upgrade_main_savepoint(true, 2011110200.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011111500.01) {
|
||||
// Remove duplicate entries from groupings_groups table
|
||||
$sql = 'SELECT MIN(id) AS firstid, groupingid, groupid FROM {groupings_groups} '.
|
||||
'GROUP BY groupingid, groupid HAVING COUNT(id)>1';
|
||||
$badrecs = $DB->get_records_sql($sql);
|
||||
foreach ($badrecs as $badrec) {
|
||||
$where = 'groupingid = ? and groupid = ? and id > ?';
|
||||
$params = array($badrec->groupingid, $badrec->groupid, $badrec->firstid);
|
||||
$DB->delete_records_select('groupings_groups', $where, $params);
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2011111500.01);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue