-
Bug
-
Resolution: Fixed
-
Major
-
2.8.3, 2.8.6, 2.9.4, 3.0.2, 3.1
-
MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
-
MOODLE_29_STABLE, MOODLE_30_STABLE
-
MDL-50310-master-random-glossary -
Moderate
-
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)
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.