From: Frederic Massart Date: Tue, 24 May 2016 09:01:33 +0000 (+0800) Subject: MDL-35987 qtype_multianswer: Prevent restore failure due to bad sequence X-Git-Tag: v3.2.0-beta~1072^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=9a601adc9e2516725e12e3d097b5fa1024a1e020;ds=sidebyside MDL-35987 qtype_multianswer: Prevent restore failure due to bad sequence --- diff --git a/question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php b/question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php index c61c2dd5f5c..80865b11523 100644 --- a/question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php +++ b/question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php @@ -102,7 +102,11 @@ class restore_qtype_multianswer_plugin extends restore_qtype_plugin { AND bi.itemname = 'question_created'", array($this->get_restoreid())); foreach ($rs as $rec) { - $sequencearr = explode(',', $rec->sequence); + $sequencearr = preg_split('/,/', $rec->sequence, -1, PREG_SPLIT_NO_EMPTY); + if (substr_count($rec->sequence, ',') + 1 != count($sequencearr)) { + $this->task->log('Invalid sequence found in restored multianswer question ' . $rec->id, backup::LOG_WARNING); + } + foreach ($sequencearr as $key => $question) { $sequencearr[$key] = $this->get_mappingid('question', $question); }