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-07-25 11:44:44 +08:00
parent 482abd0f70
commit 68e50bc80b

View File

@ -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;
}