From 7951fd129cd78c333ff68851d13c41af47288621 Mon Sep 17 00:00:00 2001 From: Jane Adelmann Date: Fri, 26 Apr 2019 15:01:08 +0300 Subject: [PATCH] Handle situation when we can not receive file. --- lib.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib.php b/lib.php index 8317731..1687b75 100644 --- a/lib.php +++ b/lib.php @@ -560,6 +560,21 @@ display: inline-block;" $moodlesubmission = $DB->get_record('assign_submission', array('assignment' => $cm->instance, 'userid' => $filedb->userid, 'id' => $filedb->itemid), 'id'); $file = $fs->get_file_by_id($filedb->fileid); + + // We can not receive file by id. + // Maybe file does not exist anymore. + // So we mark it as error and continue. + if (!$file || !is_object($file)) { + $filedbnew = new stdClass(); + $filedbnew->id = $filedb->id; + $filedbnew->attempt = $filedb->attempt + 1; + $filedbnew->state = 11; // Sending error. + + $DB->update_record('plagiarism_pchkorg_files', $filedbnew); + + continue; + } + if ($apiprovider->is_group_token()) { $textid = $apiprovider->send_group_text( $apiprovider->user_email_to_hash($user->email),