MDL-44257 message: check if the attachment exists before remove it

Credit goes to Mark Nielsen, thanks.
This commit is contained in:
Simey Lameze
2014-09-16 10:38:09 +08:00
parent 35143c155f
commit 0e32d35eff
@@ -88,7 +88,9 @@ class message_output_email extends message_output {
$eventdata->fullmessagehtml, $attachment, $attachname);
// Remove an attachment file if any.
@unlink($attachment);
if (!empty($attachment) && file_exists($CFG->dataroot.'/'.$attachment)) {
unlink($CFG->dataroot.'/'.$attachment);
}
return $result;
}