From 501cdba3a7bc30a126e089c6f8500c1e2dbcc392 Mon Sep 17 00:00:00 2001 From: gbateson Date: Thu, 30 Oct 2008 06:21:13 +0000 Subject: [PATCH] use "md5key" as secondary key on hotpot_strings table; allow for non-unique secondary keys on hotpot tables (can happen on hotpot_strings) --- mod/hotpot/restorelib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index 140a388b0ff..c0a4d506e45 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -122,7 +122,7 @@ function hotpot_restore_strings(&$restore, $status, &$xml, &$record) { // $xml is an XML tree for a hotpot record // $record is the newly added hotpot record return hotpot_restore_records( - $restore, $status, $xml, 'hotpot_strings', array(), '', 'STRING_DATA', 'STRING', 'string' + $restore, $status, $xml, 'hotpot_strings', array(), '', 'STRING_DATA', 'STRING', 'md5key' ); } function hotpot_restore_questions(&$restore, $status, &$xml, &$record) { @@ -387,9 +387,10 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, // if there is a secondary key field ... if ($secondary_key) { // check to see if a record with the same value already exists - $key_record = get_record($table, $secondary_key, $record->$secondary_key); - if ($key_record) { + $key_records = get_records($table, $secondary_key, $record->$secondary_key); + if ($key_records) { // set new record id from already existing record + $key_record = reset($key_records); $record->id = $key_record->id; } }