- Create a course custom field of any type
- Set its visibility to Teachers
- Create a course
- Go to course settings
- Set a value of the custom field in step 1
- Backup the course
- Restore the course
You should see an error:
Can't find data record in database table course.
Debug info: SELECT id,category FROM {course} WHERE id = ?
[array (
0 => 10,
)]
Stack trace: * line 1659 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
- line 1635 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
- line 200 of /lib/classes/context/course.php: call to moodle_database->get_record()
- line 65 of /backup/util/checks/restore_check.class.php: call to core\context\course::instance()
- line 217 of /backup/controller/restore_controller.class.php: call to restore_check::check_security()
- line 95 of /backup/util/ui/base_ui.class.php: call to restore_controller->process_ui_event()
- line 106 of /backup/restore.php: call to base_ui->__construct()
I traced the source of the bug to this line; get_instance_context() expects a course ID, however, in this case a custom field ID is supplied - hence the missing record exception.
I'm guessing this bug was introduced by MDL-79151, specifically course/classes/customfield/course_handler.php returning an ID. I'm afraid I don't have any suggestions for fixing it.
- duplicates
-
MDL-82877 Custom fields - Restore Course Backup Cannot Be Completed
-
- Closed
-