Fixed exception being thrown when deleted image is selected

This commit is contained in:
Mark Nelson 2017-08-27 16:19:08 +08:00
parent 33d2f65e56
commit c26dce0e79

View file

@ -151,7 +151,7 @@ class element extends \mod_customcert\element {
if (!empty($data->fileid)) {
// Array of data we will be storing in the database.
$fs = get_file_storage();
$file = $fs->get_file_by_id($data->fileid);
if ($file = $fs->get_file_by_id($data->fileid)) {
$arrtostore += [
'contextid' => $file->get_contextid(),
'filearea' => $file->get_filearea(),
@ -160,6 +160,7 @@ class element extends \mod_customcert\element {
'filename' => $file->get_filename(),
];
}
}
return json_encode($arrtostore);
}