MDL-58904 backup: old backups do not contain new fields
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 11 May 2017 17:55:21 +0000 (19:55 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 11 May 2017 17:55:21 +0000 (19:55 +0200)
Hence we need to apply DB defaults for them when missing:

  - type = 0
  - timesort = null

backup/moodle2/restore_stepslib.php

index b23fda4..0a715ad 100644 (file)
@@ -2705,11 +2705,11 @@ class restore_calendarevents_structure_step extends restore_structure_step {
                 'userid'         => $data->userid,
                 'repeatid'       => $this->get_mappingid('event', $data->repeatid),
                 'modulename'     => $data->modulename,
-                'type'           => $data->type,
+                'type'           => isset($data->type) ? $data->type : 0,
                 'eventtype'      => $data->eventtype,
                 'timestart'      => $this->apply_date_offset($data->timestart),
                 'timeduration'   => $data->timeduration,
-                'timesort'       => $this->apply_date_offset($data->timesort),
+                'timesort'       => isset($data->timesort) ? $this->apply_date_offset($data->timesort) : null,
                 'visible'        => $data->visible,
                 'uuid'           => $data->uuid,
                 'sequence'       => $data->sequence,