MDL-67294 assignsubmission_file: Make sure record exists before updating
authorMihail Geshoski <mihail@moodle.com>
Fri, 12 Jun 2020 00:55:30 +0000 (08:55 +0800)
committerMihail Geshoski <mihail@moodle.com>
Tue, 16 Jun 2020 16:55:46 +0000 (00:55 +0800)
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);
-        $currentsubmission->numfiles = 0;
-        $DB->update_record('assignsubmission_file', $currentsubmission);
+        if ($currentsubmission) {
+            $currentsubmission->numfiles = 0;
+            $DB->update_record('assignsubmission_file', $currentsubmission);
+        }
 
         return true;
     }