Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29350 Prevent memory/time problems if there are zillions of combi…

…nations
  • Loading branch information...
commit 2b38c7bea5184fe9e418273a4dc5577345623fb4 1 parent 6c628d4
@stronk7 stronk7 authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/db/upgrade.php
View
6 lib/db/upgrade.php
@@ -6680,15 +6680,17 @@ function xmldb_main_upgrade($oldversion) {
}
if ($oldversion < 2011070102.08) {
+ upgrade_set_timeout(60*20); // this may take a while
// 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) {
+ $badrs = $DB->get_recordset_sql($sql);
+ foreach ($badrs as $badrec) {
$where = 'groupingid = ? and groupid = ? and id > ?';
$params = array($badrec->groupingid, $badrec->groupid, $badrec->firstid);
$DB->delete_records_select('groupings_groups', $where, $params);
}
+ $badrs->close();
// Main savepoint reached
upgrade_main_savepoint(true, 2011070102.08);
Please sign in to comment.
Something went wrong with that request. Please try again.