ignore msg copy errors when messages are deleted. Most common error is related
[squirrelmail.git] / functions / imap_messages.php
index f16b5d2b7ffcb3331b6f00ffc9ba4dbbac802285..d99bcebd7aa22e34f8e8331181b7713d30142fb2 100755 (executable)
@@ -69,16 +69,15 @@ function sqimap_msgs_list_delete($imap_stream, $mailbox, $id, $bypass_trash=fals
     // FIX ME, remove globals by introducing an associative array with properties
     // as 4th argument as replacement for the bypass_trash var
     global $move_to_trash, $trash_folder;
-    $bRes = true;
     if (($move_to_trash == true) && ($bypass_trash != true) &&
         (sqimap_mailbox_exists($imap_stream, $trash_folder) &&  ($mailbox != $trash_folder)) ) {
-        $bRes = sqimap_msgs_list_copy ($imap_stream, $id, $trash_folder);
-    }
-    if ($bRes) {
-        return sqimap_toggle_flag($imap_stream, $id, '\\Deleted', true, true);
-    } else {
-        return false;
+        /**
+         * turn off internal error handling (fourth argument = false) and
+         * ignore copy to trash errors (allows to delete messages when overquota)
+         */
+        sqimap_msgs_list_copy ($imap_stream, $id, $trash_folder, false);
     }
+    return sqimap_toggle_flag($imap_stream, $id, '\\Deleted', true, true);
 }
 
 
@@ -923,7 +922,7 @@ function sqimap_get_message($imap_stream, $id, $mailbox) {
     if ($read) {
         if (preg_match('/.+FLAGS\s\((.*)\)\s/AUi',$read[0],$regs)) {
             if (trim($regs[1])) {
-                $flags = preg_split('/ /', $regs[1],-1,'PREG_SPLIT_NI_EMPTY');
+                $flags = preg_split('/ /', $regs[1],-1,PREG_SPLIT_NO_EMPTY);
             }
         }
     } else {
@@ -944,5 +943,3 @@ function sqimap_get_message($imap_stream, $id, $mailbox) {
     $msg->rfc822_header = $rfc822_header;
     return $msg;
 }
-
-?>