Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83326

Restoring courses with custom fields breaks when visibility is Teachers

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.4
    • Backup, Course
    • None
    • MOODLE_404_STABLE

      1. Create a course custom field of any type
      2. Set its visibility to Teachers
      3. Create a course
      4. Go to course settings
      5. Set a value of the custom field in step 1
      6. Backup the course
      7. 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.

            Unassigned Unassigned
            mjrox Matt Reid
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.