Skip to content

Commit

Permalink
MDL-25019 backup - course_startdate may not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Nov 24, 2010
1 parent f2956c9 commit 636444e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions backup/util/plan/base_step.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ protected function get_setting($name) {
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');
Expand Down
4 changes: 4 additions & 0 deletions backup/util/plan/base_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function get_setting($name) {
}
}

public function setting_exists($name) {
return $this->plan->setting_exists($name);
}

public function get_setting_value($name) {
return $this->get_setting($name)->get_value();
}
Expand Down
9 changes: 6 additions & 3 deletions backup/util/plan/restore_structure_step.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,13 @@ public function apply_date_offset($value) {
}
// 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)
Expand Down

0 comments on commit 636444e

Please sign in to comment.