From 6854fbf9a25b2139e50935c1b79628fb2b544d13 Mon Sep 17 00:00:00 2001 From: Rex Lorenzo Date: Sun, 13 Oct 2013 22:18:28 -0700 Subject: [PATCH] MDL-42319 - Specially crafted restore file can hang system * Removing part of restore code that blindly created missing sections. --- backup/moodle2/restore_stepslib.php | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 9fa8a9b..4b5ac95 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -455,30 +455,12 @@ class restore_decode_interlinks extends restore_execution_step { } /** - * first, ensure that we have no gaps in section numbers - * and then, rebuid the course cache + * Rebuid the course cache. */ class restore_rebuild_course_cache extends restore_execution_step { protected function define_execution() { - global $DB; - - // Although there is some sort of auto-recovery of missing sections - // present in course/formats... here we check that all the sections - // from 0 to MAX(section->section) exist, creating them if necessary - $maxsection = $DB->get_field('course_sections', 'MAX(section)', array('course' => $this->get_courseid())); - // Iterate over all sections - for ($i = 0; $i <= $maxsection; $i++) { - // If the section $i doesn't exist, create it - if (!$DB->record_exists('course_sections', array('course' => $this->get_courseid(), 'section' => $i))) { - $sectionrec = array( - 'course' => $this->get_courseid(), - 'section' => $i); - $DB->insert_record('course_sections', $sectionrec); // missing section created - } - } - - // Rebuild cache now that all sections are in place + // Rebuild caches. rebuild_course_cache($this->get_courseid()); cache_helper::purge_by_event('changesincourse'); cache_helper::purge_by_event('changesincoursecat'); -- 1.8.3.1