MDL-67294 assignsubmission_file: Make sure record exists before updating
[moodle.git] / mod / assign / submission / file / locallib.php
index e0e0539..382c3b3 100644 (file)
@@ -323,8 +323,10 @@ class assign_submission_file extends assign_submission_plugin {
                                $submission->id);
 
         $currentsubmission = $this->get_file_submission($submission->id);
                                $submission->id);
 
         $currentsubmission = $this->get_file_submission($submission->id);
-        $currentsubmission->numfiles = 0;
-        $DB->update_record('assignsubmission_file', $currentsubmission);
+        if ($currentsubmission) {
+            $currentsubmission->numfiles = 0;
+            $DB->update_record('assignsubmission_file', $currentsubmission);
+        }
 
         return true;
     }
 
         return true;
     }