-
Bug
-
Resolution: Fixed
-
Minor
-
4.0.3, 4.0.4
While restoreing a course backup from moodle 2.* to moodle 4.* i observed the following error:
error/moodle/dmlwriteexception
with debugging enabled the error is:
ERROR: null value in column "questionbankentryid" of relation "mdl_question_references" violates not-null constraint
|
DETAIL: Failing row contains (57, 328328, mod_quiz, slot, 142, null, null).
|
INSERT INTO mdl_question_references (usingcontextid,component,questionarea,itemid,questionbankentryid,version) VALUES($1,$2,$3,$4,$5,$6) RETURNING id
|
[array (
|
'usingcontextid' => 328328,
|
'component' => 'mod_quiz',
|
'questionarea' => 'slot',
|
'itemid' => 142,
|
'questionbankentryid' => NULL,
|
'version' => NULL,
|
)]
|
Error code: dmlwriteexception
|
Callstack:
|
|
line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
|
line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
|
line 1113 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
|
line 1161 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->insert_record_raw()
|
line 357 of /mod/quiz/backup/moodle2/restore_quiz_stepslib.php: call to pgsql_native_moodle_database->insert_record()
|
line 414 of /mod/quiz/backup/moodle2/restore_quiz_stepslib.php: call to restore_quiz_activity_structure_step->process_quiz_question_legacy_instance()
|
line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_quiz_activity_structure_step->process_quiz_question_instance()
|
line 121 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
|
line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
|
line 109 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
|
line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
|
line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
|
line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
|
line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
|
line ? of unknownfile: call to progressive_parser->end_tag()
|
line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
|
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
|
line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
|
line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
|
line 219 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
|
line 191 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
|
line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
|
line 408 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
|
line 219 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
|
line 144 of /backup/restore.php: call to restore_ui->execute()
|
After further investigation the problem is that in
$question = $DB->get_record_sql($sql, [$questionid]); line $question might be bool type false.
but after that line $question is not checled just used as if is were an array. And in line $questionreference->questionbankentryid = $question->questionbankentryid; $question->questionbankentryid is false->questionbankentryid which is undef, which will be null in the sql insert in $DB->insert_record('question_references', $questionreference); line.
Additionally, while testing a lot of PHP Warnings "Undefined array key 1" were emitted. This is due to various version checks using restore_controller::info::moodle_release rather than moodle_version when comparing to a YYYYMMDD version number to decide whether to perform conversion from old data structures during the restore.
- is duplicated by
-
MDL-77664 Can't restore a backup from Moodle 3.9 or 3.11 into 4.1 with quiz
-
- Closed
-