瀏覽代碼

fixed warning when attachments aren't set

stekkel 22 年之前
父節點
當前提交
7dec4b6aad
共有 1 個文件被更改,包括 11 次插入9 次删除
  1. 11 9
      src/read_body.php

+ 11 - 9
src/read_body.php

@@ -320,15 +320,17 @@ function ClearAttachments() {
     $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
     $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
 
 
     $rem_attachments = array();
     $rem_attachments = array();
-    foreach ($attachments as $info) {
-        if ($info['session'] == -1) {
-            $attached_file = "$hashed_attachment_dir/$info[localfilename]";
-            if (file_exists($attached_file)) {
-                unlink($attached_file);
-            }
-        } else {
-            $rem_attachments[] = $info;
-        }
+    if (isset($attachments)) {
+	foreach ($attachments as $info) {
+    	    if ($info['session'] == -1) {
+        	$attached_file = "$hashed_attachment_dir/$info[localfilename]";
+        	if (file_exists($attached_file)) {
+            	    unlink($attached_file);
+        	}
+    	    } else {
+        	$rem_attachments[] = $info;
+    	    }
+	}
     }
     }
     $attachments = $rem_attachments;
     $attachments = $rem_attachments;
 }
 }