Permalink
Browse files

Merge branch 'MDL-29350-MOODLE_20_STABLE-2' of git://git.luns.net.uk/…

…moodle into MOODLE_20_STABLE
  • Loading branch information...
2 parents 165e476 + fc73d9e commit da7ab3476254725fb722da10eb3fa5c918b8a243 @stronk7 stronk7 committed Nov 17, 2011
Showing with 24 additions and 2 deletions.
  1. +8 −1 backup/moodle2/restore_stepslib.php
  2. +15 −0 lib/db/upgrade.php
  3. +1 −1 version.php
@@ -792,7 +792,14 @@ public function process_grouping_group($data) {
$data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
$data->groupid = $this->get_mappingid('group', $data->groupid); // Get from mappings
- $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+
+ $params = array();
+ $params['groupingid'] = $data->groupingid;
+ $params['groupid'] = $data->groupid;
+
+ if (!$DB->record_exists('groupings_groups', $params)) {
+ $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+ }
}
protected function after_execute() {
View
@@ -6160,6 +6160,21 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011033004.09);
}
+ if ($oldversion < 2011033005.07) {
+ // 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, 2011033005.07);
+ }
+
return true;
}
View
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2011033005.06; // 20110330 = branching date YYYYMMDD - do not modify!
+$version = 2011033005.07; // 20110330 = branching date YYYYMMDD - do not modify!
// RR = release version - do not change in weeklies
// .XX = incremental changes

0 comments on commit da7ab34

Please sign in to comment.