From c957afd1e88453c75ab24e94c163c23cf8a10b26 Mon Sep 17 00:00:00 2001 From: jangliss Date: Thu, 11 Aug 2005 03:43:08 +0000 Subject: [PATCH] Don't attempt to delete a mailbox that does not exist. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9928 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 2 ++ functions/imap_mailbox.php | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 490fabdb..b3f1f6a3 100644 --- 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 ------------------------------- diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 827a83dc..3be48cdd 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -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 +?> -- 2.25.1