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

Restore fails with database record not found

XMLWordPrintable

    • MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-50310-master-random-glossary
    • Moderate
    • Hide
      1. Prepare a site with no existing glossaries (table mdl_glossary is empty).
      2. Restore the attached mdl-50310-block-only.mbz file.
      3. TEST: Make sure you can visit the restored course and there is an instance of the Random glossary entry block, not configured
      4. Create a first glossary on the site and check that it has id=1 in the database table mdl_glossary. If you do not have access to the database, you can check this by testing that you are able to access the glossary via URL like mod/glossary/view.php?g=1
      5. Restore the file mdl-50310-block-only.mbz file again.
      6. TEST: Make sure that even in this case, the block in the backup file restores into a new instance that is not associated with any glossary (i.e. is not configured).
      7. Restore the file mdl-50310-block-with-glossary.mbz
      8. TEST: Make sure that the backup is restored into a course with a glossary and a block, and that the block is associated with that glossary.
      Show
      Prepare a site with no existing glossaries (table mdl_glossary is empty). Restore the attached mdl-50310-block-only.mbz file. TEST: Make sure you can visit the restored course and there is an instance of the Random glossary entry block, not configured Create a first glossary on the site and check that it has id=1 in the database table mdl_glossary . If you do not have access to the database, you can check this by testing that you are able to access the glossary via URL like mod/glossary/view.php?g=1 Restore the file mdl-50310-block-only.mbz file again. TEST: Make sure that even in this case, the block in the backup file restores into a new instance that is not associated with any glossary (i.e. is not configured). Restore the file mdl-50310-block-with-glossary.mbz TEST: Make sure that the backup is restored into a course with a glossary and a block, and that the block is associated with that glossary.

      Backing up a course in 2.8.3 and restoring to 2.8.6 throws an error "Can not find data record in database table course." I have verified that the record exists and completed a stack trace.

      Debug info: SELECT * FROM

      {course}

      WHERE id = ?
      [array (
      0 => '18',
      )]
      Error code: invalidrecord
      Stack trace:

      line 1451 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
      line 1427 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      line 592 of /lib/datalib.php: call to moodle_database->get_record()
      line 443 of /lib/modinfolib.php: call to get_course()
      line 412 of /lib/modinfolib.php: call to course_modinfo->__construct()
      line 2098 of /lib/modinfolib.php: call to course_modinfo::instance()
      line 195 of /blocks/glossary_random/block_glossary_random.php: call to get_fast_modinfo()
      line 288 of /blocks/moodleblock.class.php: call to block_glossary_random->get_content()
      line 230 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      line 971 of /lib/blocklib.php: call to block_base->get_content_for_output()
      line 1023 of /lib/blocklib.php: call to block_manager->create_block_contents()
      line 392 of /lib/outputrenderers.php: call to block_manager->ensure_content_created()
      line 45 of /theme/geneva/layout/columns3.php: call to core_renderer->standard_head_html()
      line 915 of /lib/outputrenderers.php: call to include()
      line 845 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line 245 of /course/view.php: call to core_renderer->header()Debug info: SELECT * FROM

      I've further investigated the issue and added some checks in the code of file datalib.php

      function get_course($courseid, $clone = true) {
      echo "here". $courseid;
      global $DB, $COURSE, $SITE;
      if (!empty($COURSE->id) && $COURSE->id == $courseid)

      { echo "making clone - loaded"; return $clone ? clone($COURSE) : $COURSE; }

      else if (!empty($SITE->id) && $SITE->id == $courseid)

      { echo "making clone - loaded site"; return $clone ? clone($SITE) : $SITE; }

      else

      { echo "getting record from db"; return $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); }

      }

      The echo statements return the following info:

      here1making clone - loaded sitehere5making clone - loadedhere18getting record from db

      which seems to show that for some reason it's trying to get record from course table with id 18 (doesn't exist) whereas it should want record with id 5 (id of the restored course as it appears in the course table).

      I've tried this with the same backup files from 2.8.3 on two different sites with the same result. Both sites are running MySQL, one site is over Debian Squeeze and the other CentOS.

      I've tried this with two different backup files with the same result. By the way it does seem to be fixated on record 18 for some reason - same SQL on both sites even though they have different numbers of courses.

      To reproduce the problem: Take a backup from 2.8.3 and try to restore to 2.8.6.

            mudrd8mz David Mudrák (@mudrd8mz)
            richardnz Richard Jones
            Mark Nelson Mark Nelson
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Andrew Lyons Andrew Lyons
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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