Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SQL to update clickreportid must be done one statement at a time

  • Loading branch information...
commit d4e351cd8b882144d874325a71d31bdf9a70fdcc 1 parent 1ee38be
gbateson authored
Showing with 3 additions and 12 deletions.
  1. +3 −12 mod/hotpot/restorelib.php
View
15 mod/hotpot/restorelib.php
@@ -146,7 +146,7 @@ function hotpot_restore_attempts(&$restore, $status, &$xml, &$record, $hotpot_v2
$more_restore .= '$status = hotpot_restore_responses($restore, $status, $xml, $record);';
// save clickreportid (to be updated it later)
- $more_restore .= 'if (isset($record->clickreportid)) {';
+ $more_restore .= 'if (!empty($record->clickreportid)) {';
$more_restore .= '$GLOBALS["hotpot_backup_clickreportids"][$record->id]=$record->clickreportid;';
$more_restore .= '}';
@@ -178,13 +178,12 @@ function hotpot_restore_attempts(&$restore, $status, &$xml, &$record, $hotpot_v2
function hotpot_restore_clickreportids(&$restore, $status) {
// update clickreport ids, if any
global $CFG;
- $sql = '';
foreach ($GLOBALS["hotpot_backup_clickreportids"] as $id=>$clickreportid) {
if ($status) {
$attempt_record = backup_getid($restore->backup_unique_code, 'hotpot_attempts', $clickreportid);
if ($attempt_record) {
$new_clickreportid = $attempt_record->new_id;
- $sql .= "UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=$new_clickreportid WHERE id=$id;\n";
+ $status = execute_sql("UPDATE {$CFG->prefix}hotpot_attempts SET clickreportid=$new_clickreportid WHERE id=$id", false);
} else {
// New clickreport id could not be found
print "<ul><li>New clickreportid could not be found: attempt id=$id, clickreportid=$clickreportid</li></ul>";
@@ -192,14 +191,6 @@ function hotpot_restore_clickreportids(&$restore, $status) {
}
}
}
- if ($status && $sql) {
- if (execute_sql($sql, false)) {
- // do nothing (update was ok :-)
- } else {
- print "<ul><li>Clickreportids could not be updated</li></ul>";
- $status = false;
- }
- }
return $status;
}
function hotpot_restore_responses(&$restore, $status, &$xml, &$record) {
@@ -213,7 +204,7 @@ function hotpot_restore_responses(&$restore, $status, &$xml, &$record) {
'wrong'=>'hotpot_strings',
'ignored'=>'hotpot_strings'
);
-
+
return hotpot_restore_records(
$restore, $status, $xml, 'hotpot_responses', $foreignkeys, '', 'RESPONSE_DATA', 'RESPONSE'
);
Please sign in to comment.
Something went wrong with that request. Please try again.