-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
4.0.3
-
None
-
MOODLE_400_STABLE
If the system contextlevel (10) is not id = 1 in mdl_context then you get an error when you try to preview questions: "Can't find data record in database table context.".
Steps to reproduce issue
- Set up a Moodle 4.0 site.
- Edit the database to simulate the system contextlevel having ID ≠ 1:
- DELETE FROM mdl_context WHERE id = 1;
- INSERT INTO mdl_context (contextlevel, path, depth) VALUES (10, '/1', 1);
- Rebuild the context paths following step B (in short: change line 49 of lib/classes/task/context_cleanup_task.php to true, then run \core\task\context_cleanup_task).
- Purge caches using the command line (for example: sudo -u apache php admin/cli/purge_caches.php).
- Add a course.
- Add a quiz to the course.
- Add a question to the quiz.
- Click the magnifying glass icon (Preview question).
Expected results
A window pops up showing the preview of the question.
Actual results
The error message "Can't find data record in database table context." appears in red. With debugging enabled:
Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => 1,
)]
Error code: invalidrecord
Stack trace:
line 1646 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 5353 of /lib/accesslib.php: call to moodle_database->get_record()
line 136 of /comment/lib.php: call to context::instance_by_id()
line 96 of /question/bank/comment/lib.php: call to comment->__construct()
line 8013 of /lib/moodlelib.php: call to qbank_comment_preview_display()
line 265 of /question/bank/previewquestion/classes/helper.php: call to component_callback()
line 286 of /question/bank/previewquestion/preview.php: call to qbank_previewquestion\helper::get_preview_extra_elements()
- duplicates
-
MDL-75351 Cannot comment a question when system context id is not 1
- Closed
- links to