MDL-25019 backup - course_startdate may not exist
authorEloy Lafuente <stronk7@moodle.org>
Wed, 24 Nov 2010 10:46:15 +0000 (10:46 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Wed, 24 Nov 2010 10:46:15 +0000 (10:46 +0000)
backup/util/plan/base_step.class.php
backup/util/plan/base_task.class.php
backup/util/plan/restore_structure_step.class.php

index e1bc116..66f1f6b 100644 (file)
@@ -88,6 +88,13 @@ abstract class base_step implements executable, loggable {
         return $this->task->get_setting($name);
     }
 
+    protected function setting_exists($name) {
+        if (is_null($this->task)) {
+            throw new base_step_exception('not_specified_base_task');
+        }
+        return $this->task->setting_exists($name);
+    }
+
     protected function get_setting_value($name) {
         if (is_null($this->task)) {
             throw new base_step_exception('not_specified_base_task');
index e38fa89..1527634 100644 (file)
@@ -87,6 +87,10 @@ abstract class base_task implements checksumable, executable, loggable {
         }
     }
 
+    public function setting_exists($name) {
+        return $this->plan->setting_exists($name);
+    }
+
     public function get_setting_value($name) {
         return $this->get_setting($name)->get_value();
     }
index aef63fa..2d1c6d7 100644 (file)
@@ -213,10 +213,13 @@ abstract class restore_structure_step extends restore_step {
         }
         // No cache, let's calculate the offset
         $original = $this->task->get_info()->original_course_startdate;
-        $setting  = $this->get_setting_value('course_startdate');
+        $setting = 0;
+        if ($this->setting_exists('course_startdate')) { // Seting may not exist (MDL-25019)
+            $setting  = $this->get_setting_value('course_startdate');
+        }
 
-        // Original course has not startdate, offset = 0
-        if (empty($original)) {
+        // Original course has not startdate or setting doesn't exist, offset = 0
+        if (empty($original) || empty($setting)) {
             $cache[$this->get_restoreid()] = 0;
 
         // Less than 24h of difference, offset = 0 (this avoids some problems with timezones)