Don't attempt to delete a mailbox that does not exist.
authorjangliss <jangliss@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 11 Aug 2005 03:43:08 +0000 (03:43 +0000)
committerjangliss <jangliss@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 11 Aug 2005 03:43:08 +0000 (03:43 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9928 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
functions/imap_mailbox.php

index 490fabdb69ebc2fa1cdbc7a2a10433b23104f9c4..b3f1f6a31d58fdb1b985d3bf3f695f1a6014b444 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -425,6 +425,8 @@ Version 1.5.1 -- CVS
   - Removed function references from address book database backend class, 
     list_addr(), lookup() and search() functions. Referenced lookup() 
     function caused E_NOTICE warnings in php 4.4.0. Reported by Cor Bosman.
+  - Test to ensure folder exists before attempting to delete it, otherwise
+    IMAP server will return an error.
 
 Version 1.5.0 - 2 February 2004
 -------------------------------
index 827a83dc1b723bcd58d3040fa9ac87dab452c800..3be48cdd436964c73a3e8a0e0a65db1df2fdb8dd 100755 (executable)
@@ -431,16 +431,20 @@ function sqimap_unsubscribe ($imap_stream, $mailbox) {
 function sqimap_mailbox_delete ($imap_stream, $mailbox) {
     global $data_dir, $username;
     sqimap_unsubscribe ($imap_stream, $mailbox);
-    $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
-                                   sqimap_encode_mailbox_name($mailbox),
-                                   true, $response, $message);
-    if ($response !== 'OK') {
-        // subscribe again
-        sqimap_subscribe ($imap_stream, $mailbox);
-    } else {
-        do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
-        removePref($data_dir, $username, "thread_$mailbox");
-        removePref($data_dir, $username, "collapse_folder_$mailbox");
+
+    if (sqimap_mailbox_exists($imap_stream, $mailbox)) {
+
+        $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
+                                       sqimap_encode_mailbox_name($mailbox),
+                                       true, $response, $message);
+        if ($response !== 'OK') {
+            // subscribe again
+            sqimap_subscribe ($imap_stream, $mailbox);
+        } else {
+            do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
+            removePref($data_dir, $username, "thread_$mailbox");
+            removePref($data_dir, $username, "collapse_folder_$mailbox");
+        }
     }
 }
 
@@ -1207,4 +1211,4 @@ function sqimap_get_status_mbx_tree($imap_stream,&$mbx_tree) {
     }
 }
 
-?>
\ No newline at end of file
+?>