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

Restoring course throws an exception

    Details

    • Testing Instructions:
      Hide

      Test pre-requisites

      • Create 2 courses with the exact same name (not short name)
      • Backup one of them

      Test steps

      1. Go to the restore page of the backed up course.
      2. Restore it as a new course
      3. Make sure no errors or exceptions occur
      Show
      Test pre-requisites Create 2 courses with the exact same name (not short name) Backup one of them Test steps Go to the restore page of the backed up course. Restore it as a new course Make sure no errors or exceptions occur
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-34837-master

      Description

      There is an error in method for generating new temporary name for a restored course. Method is located in
      <moodle>/backup/util/dbops/restore_dbops.class.php

      restore_dbops::calculate_course_names

      That method uses

      $DB->get_record_select

      Which throws exception if query returns more than one record and debugging is turned on. It does not break anything but it annoys suspicious users(clients).

      Quick fix would be to change these lines:

      $coursefull  = $DB->get_record_select('course', 'fullname = ? AND id != ?', array($currentfullname, $courseid));
      $courseshort = $DB->get_record_select('course', 'shortname = ? AND id != ?', array($currentshortname, $courseid));

      To:

      $coursefull  = $DB->get_record_select('course', 'fullname = ? AND id != ?', array($currentfullname, $courseid), IGNORE_MULTIPLE);
      $courseshort = $DB->get_record_select('course', 'shortname = ? AND id != ?', array($currentshortname, $courseid), IGNORE_MULTIPLE);

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Nov/12