Permalink
Browse files

MDL-32499 gradingform_rubric Avoid backup/restore of rubric fillings …

…without an existing criteria
  • Loading branch information...
1 parent 6975216 commit 2011579b26674c15b67c9203a107088ae1fe048e @dmonllao dmonllao committed Jul 20, 2012
@@ -106,8 +106,13 @@ protected function define_instance_plugin_structure() {
// Set sources to populate the data
- $filling->set_source_table('gradingform_rubric_fillings',
- array('instanceid' => backup::VAR_PARENTID));
+ // MDL-32499 Binding criterionid to ensure it's existence
+ $filling->set_source_sql('SELECT rf.*
+ FROM {gradingform_rubric_fillings} rf
+ JOIN {grading_instances} gi ON gi.id = rf.instanceid
+ JOIN {gradingform_rubric_criteria} rc ON rc.id = rf.criterionid AND gi.definitionid = rc.definitionid
+ WHERE rf.instanceid = :instanceid',
+ array('instanceid' => backup::VAR_PARENTID));
// no need to annotate ids or files yet (one day when remark field supports
// embedded fileds, they must be annotated here)
@@ -109,6 +109,10 @@ public function process_gradinform_rubric_filling($data) {
$data->criterionid = $this->get_mappingid('gradingform_rubric_criterion', $data->criterionid);
$data->levelid = $this->get_mappingid('gradingform_rubric_level', $data->levelid);
- $DB->insert_record('gradingform_rubric_fillings', $data);
+ // MDL-32499 Avoid fatal errors when restoring backups created after patching MDL-32499
+ if (!empty($data->criterionid)) {
+ $DB->insert_record('gradingform_rubric_fillings', $data);
+ }
+
}
}

0 comments on commit 2011579

Please sign in to comment.