MDL-44257 message: check if the attachment exists before remove it
authorSimey Lameze <simey@moodle.com>
Fri, 25 Jul 2014 03:44:44 +0000 (11:44 +0800)
committerSimey Lameze <simey@moodle.com>
Fri, 12 Sep 2014 08:36:07 +0000 (16:36 +0800)
Credit goes to Mark Nielsen, thanks.

message/output/email/message_output_email.php

index cfe9fd4..4b95db1 100644 (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;
     }