MDL-31532 restore: avoid null course->hiddensections problems. Credit goes to Petri...
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 20 Feb 2012 00:34:25 +0000 (01:34 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 20 Feb 2012 00:34:25 +0000 (01:34 +0100)
backup/moodle2/restore_stepslib.php

index 2aebdcf..acf17be 100644 (file)
@@ -1124,6 +1124,12 @@ class restore_course_structure_step extends restore_structure_step {
             unset($data->idnumber);
         }
 
+        // Any empty value for course->hiddensections will lead to 0 (default, show collapsed).
+        // It has been reported that some old 1.9 courses may have it null leading to DB error. MDL-31532
+        if (empty($data->hiddensections)) {
+            $data->hiddensections = 0;
+        }
+
         // Only restrict modules if original course was and target site too for new courses
         $data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';