MDL-59518 restore: System date info no longer rolled forward.

Only dates that are part of a configuration setting should
have the date rolled forward in a restore.
This commit is contained in:
Adrian Greeve 2017-07-18 09:14:10 +08:00 committed by Ankit Agarwal
parent 0d14fcbc60
commit 3678380cbf

View File

@ -203,9 +203,7 @@ class restore_gradebook_structure_step extends restore_structure_step {
$data->scaleid = $this->get_mappingid('scale', $data->scaleid, NULL);
$data->outcomeid = $this->get_mappingid('outcome', $data->outcomeid, NULL);
$data->locktime = $this->apply_date_offset($data->locktime);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
$data->locktime = $this->apply_date_offset($data->locktime);
$coursecategory = $newitemid = null;
//course grade item should already exist so updating instead of inserting
@ -264,10 +262,6 @@ class restore_gradebook_structure_step extends restore_structure_step {
if (!empty($data->userid)) {
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
$data->locktime = $this->apply_date_offset($data->locktime);
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
$data->overridden = $this->apply_date_offset($data->overridden);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
$gradeexists = $DB->record_exists('grade_grades', array('userid' => $data->userid, 'itemid' => $data->itemid));
if ($gradeexists) {
@ -292,9 +286,6 @@ class restore_gradebook_structure_step extends restore_structure_step {
$data->course = $this->get_courseid();
$data->courseid = $data->course;
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = null;
//no parent means a course level grade category. That may have been created when the course was created
if(empty($data->parent)) {
@ -1576,7 +1567,7 @@ class restore_section_structure_step extends restore_structure_step {
$section = new stdclass();
$section->course = $this->get_courseid();
$section->section = $data->number;
$section->timemodified = isset($data->timemodified) ? $this->apply_date_offset($data->timemodified) : 0;
$section->timemodified = $data->timemodified ?? 0;
// Section doesn't exist, create it with all the info from backup
if (!$secrec = $DB->get_record('course_sections', ['course' => $this->get_courseid(), 'section' => $data->number])) {
$section->name = $data->name;
@ -2534,8 +2525,8 @@ class restore_badges_structure_step extends restore_structure_step {
$params = array(
'name' => $data->name,
'description' => $data->description,
'timecreated' => $this->apply_date_offset($data->timecreated),
'timemodified' => $this->apply_date_offset($data->timemodified),
'timecreated' => $data->timecreated,
'timemodified' => $data->timemodified,
'usercreated' => $data->usercreated,
'usermodified' => $data->usermodified,
'issuername' => $data->issuername,
@ -2550,7 +2541,7 @@ class restore_badges_structure_step extends restore_structure_step {
'attachment' => $data->attachment,
'notification' => $data->notification,
'status' => BADGE_STATUS_INACTIVE,
'nextcron' => $this->apply_date_offset($data->nextcron)
'nextcron' => $data->nextcron
);
$newid = $DB->insert_record('badge', $params);
@ -2727,7 +2718,7 @@ class restore_calendarevents_structure_step extends restore_structure_step {
'visible' => $data->visible,
'uuid' => $data->uuid,
'sequence' => $data->sequence,
'timemodified' => $this->apply_date_offset($data->timemodified),
'timemodified' => $data->timemodified,
'priority' => isset($data->priority) ? $data->priority : null);
if ($this->name == 'activity_calendar') {
$params['instance'] = $this->task->get_activityid();
@ -2959,7 +2950,7 @@ class restore_course_completion_structure_step extends restore_structure_step {
'userid' => $data->userid,
'course' => $data->course,
'criteriaid' => $data->criteriaid,
'timecompleted' => $this->apply_date_offset($data->timecompleted)
'timecompleted' => $data->timecompleted
);
if (isset($data->gradefinal)) {
$params['gradefinal'] = $data->gradefinal;
@ -2989,9 +2980,9 @@ class restore_course_completion_structure_step extends restore_structure_step {
$params = array(
'userid' => $data->userid,
'course' => $data->course,
'timeenrolled' => $this->apply_date_offset($data->timeenrolled),
'timestarted' => $this->apply_date_offset($data->timestarted),
'timecompleted' => $this->apply_date_offset($data->timecompleted),
'timeenrolled' => $data->timeenrolled,
'timestarted' => $data->timestarted,
'timecompleted' => $data->timecompleted,
'reaggregate' => $data->reaggregate
);
@ -3693,8 +3684,6 @@ class restore_activity_grades_structure_step extends restore_structure_step {
$data->idnumber = $idnumber;
$data->scaleid = $this->get_mappingid('scale', $data->scaleid);
$data->outcomeid = $this->get_mappingid('outcome', $data->outcomeid);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
$gradeitem = new grade_item($data, false);
$gradeitem->insert('restore');
@ -3720,8 +3709,6 @@ class restore_activity_grades_structure_step extends restore_structure_step {
if (!empty($data->userid)) {
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
$data->rawscaleid = $this->get_mappingid('scale', $data->rawscaleid);
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
$data->overridden = $this->apply_date_offset($data->overridden);
$grade = new grade_grade($data, false);
$grade->insert('restore');
@ -4288,7 +4275,6 @@ class restore_userscompletion_structure_step extends restore_structure_step {
$data->coursemoduleid = $this->task->get_moduleid();
$data->userid = $this->get_mappingid('user', $data->userid);
$data->timemodified = $this->apply_date_offset($data->timemodified);
// Find the existing record
$existing = $DB->get_record('course_modules_completion', array(
@ -5204,7 +5190,6 @@ abstract class restore_questions_activity_structure_step extends restore_activit
if (!property_exists($data, 'variant')) {
$data->variant = 1;
}
$data->timemodified = $this->apply_date_offset($data->timemodified);
if (!property_exists($data, 'maxfraction')) {
$data->maxfraction = 1;
@ -5239,7 +5224,6 @@ abstract class restore_questions_activity_structure_step extends restore_activit
unset($data->response);
$data->questionattemptid = $this->get_new_parentid($nameprefix . 'question_attempt');
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->userid = $this->get_mappingid('user', $data->userid);
// Everything ready, insert and create mapping (needed by question_sessions)