From 77151075dcbfcd748c2d6445aaadbf1efaa3b723 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Wed, 24 Nov 2010 14:55:29 +0000 Subject: [PATCH] NOBUG: Changed to _sql() variant to properly use sql_compare_text(). Kudos to aparup for latest improvs. in where_clause() --- backup/moodle2/restore_qtype_plugin.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backup/moodle2/restore_qtype_plugin.class.php b/backup/moodle2/restore_qtype_plugin.class.php index 6a64cf22f1b..f3a3b70c416 100644 --- a/backup/moodle2/restore_qtype_plugin.class.php +++ b/backup/moodle2/restore_qtype_plugin.class.php @@ -126,7 +126,12 @@ abstract class restore_qtype_plugin extends restore_plugin { // The question existed, we need to map the existing question_answers } else { // Look in question_answers by answertext matching - $newitemid = $DB->get_field('question_answers', 'id', array('question' => $newquestionid, 'answer' => $data->answertext)); + $sql = 'SELECT id + FROM {question_answers} + WHERE question = ? + AND ' . $DB->sql_compare_text('answer', 255) . ' = ' . $DB->sql_compare_text('?', 255); + $params = array($newquestionid, $data->answertext); + $newitemid = $DB->get_field_sql($sql, $params); // If we haven't found the newitemid, something has gone really wrong, question in DB // is missing answers, exception if (!$newitemid) { -- 2.43.0