mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-28180 backup - take rid of dupes in course_completion_aggr_methd
Conflicts: version.php
This commit is contained in:
parent
184acafab6
commit
43cf3165f1
@ -6951,6 +6951,34 @@ FROM
|
||||
// Moodle v2.2.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
||||
if ($oldversion < 2011120500.02) {
|
||||
|
||||
upgrade_set_timeout(60*20); // This may take a while
|
||||
// MDL-28180. Some missing restrictions in certain backup & restore operations
|
||||
// were causing incorrect duplicates in the course_completion_aggr_methd table.
|
||||
// This upgrade step takes rid of them.
|
||||
$sql = 'SELECT course, criteriatype, MIN(id) AS minid
|
||||
FROM {course_completion_aggr_methd}
|
||||
GROUP BY course, criteriatype
|
||||
HAVING COUNT(*) > 1';
|
||||
$duprs = $DB->get_recordset_sql($sql);
|
||||
foreach ($duprs as $duprec) {
|
||||
// We need to handle NULLs in criteriatype diferently
|
||||
if (is_null($duprec->criteriatype)) {
|
||||
$where = 'course = ? AND criteriatype IS NULL AND id > ?';
|
||||
$params = array($duprec->course, $duprec->minid);
|
||||
} else {
|
||||
$where = 'course = ? AND criteriatype = ? AND id > ?';
|
||||
$params = array($duprec->course, $duprec->criteriatype, $duprec->minid);
|
||||
}
|
||||
$DB->delete_records_select('course_completion_aggr_methd', $where, $params);
|
||||
}
|
||||
$duprs->close();
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2011120500.02);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2011120500.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2011120500.02; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user