MDL-63798 mod_assign: fix restore when group is missing
authorDavo Smith <davo.smith@synergy-learning.com>
Mon, 29 Oct 2018 09:26:58 +0000 (09:26 +0000)
committerDavo Smith <davo.smith@synergy-learning.com>
Wed, 21 Nov 2018 07:58:11 +0000 (07:58 +0000)
mod/assign/backup/moodle2/restore_assign_stepslib.php

index d4ba0a5..179f9ed 100644 (file)
@@ -167,6 +167,11 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
         }
         if (!empty($data->groupid)) {
             $data->groupid = $this->get_mappingid('group', $data->groupid);
+            if (!$data->groupid) {
+                // If the group does not exist, then the submission cannot be viewed and restoring can
+                // violate the unique index on the submission table.
+                return;
+            }
         } else {
             $data->groupid = 0;
         }