Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-33863_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
commit 01d8f54dbd339390c8fd6951a135c36a2a643168 2 parents 81c8ccc + 2773783
@danpoltawski danpoltawski authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 backup/moodle2/restore_stepslib.php
View
16 backup/moodle2/restore_stepslib.php
@@ -2821,6 +2821,22 @@ protected function process_question_hint($data) {
AND ' . $DB->sql_compare_text('hint', 255) . ' = ' . $DB->sql_compare_text('?', 255);
$params = array($newquestionid, $data->hint);
$newitemid = $DB->get_field_sql($sql, $params);
+
+ // Not able to find the hint, let's try cleaning the hint text
+ // of all the question's hints in DB as slower fallback. MDL-33863.
+ if (!$newitemid) {
+ $potentialhints = $DB->get_records('question_hints',
+ array('questionid' => $newquestionid), '', 'id, hint');
+ foreach ($potentialhints as $potentialhint) {
+ // Clean in the same way than {@link xml_writer::xml_safe_utf8()}.
+ $cleanhint = preg_replace('/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is','', $potentialhint->hint); // Clean CTRL chars.
+ $cleanhint = preg_replace("/\r\n|\r/", "\n", $cleanhint); // Normalize line ending.
+ if ($cleanhint === $data->hint) {
+ $newitemid = $data->id;
+ }
+ }
+ }
+
// If we haven't found the newitemid, something has gone really wrong, question in DB
// is missing hints, exception
if (!$newitemid) {
Please sign in to comment.
Something went wrong with that request. Please try again.