MDL-25019 backup - course_startdate may not exist

This commit is contained in:
Eloy Lafuente 2010-11-24 10:46:15 +00:00
parent f2956c9813
commit 636444e8b6
3 changed files with 17 additions and 3 deletions

View file

@ -88,6 +88,13 @@ abstract class base_step implements executable, loggable {
return $this->task->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) { protected function get_setting_value($name) {
if (is_null($this->task)) { if (is_null($this->task)) {
throw new base_step_exception('not_specified_base_task'); throw new base_step_exception('not_specified_base_task');

View 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) { public function get_setting_value($name) {
return $this->get_setting($name)->get_value(); return $this->get_setting($name)->get_value();
} }

View file

@ -213,10 +213,13 @@ abstract class restore_structure_step extends restore_step {
} }
// No cache, let's calculate the offset // No cache, let's calculate the offset
$original = $this->task->get_info()->original_course_startdate; $original = $this->task->get_info()->original_course_startdate;
$setting = 0;
if ($this->setting_exists('course_startdate')) { // Seting may not exist (MDL-25019)
$setting = $this->get_setting_value('course_startdate'); $setting = $this->get_setting_value('course_startdate');
}
// Original course has not startdate, offset = 0 // Original course has not startdate or setting doesn't exist, offset = 0
if (empty($original)) { if (empty($original) || empty($setting)) {
$cache[$this->get_restoreid()] = 0; $cache[$this->get_restoreid()] = 0;
// Less than 24h of difference, offset = 0 (this avoids some problems with timezones) // Less than 24h of difference, offset = 0 (this avoids some problems with timezones)