Add sanity check when auto-unsubscribing non-existing folders

pull/6204/head
Aleksander Machniak 7 years ago
parent 656f979831
commit 6bfebc5e32

@ -2931,12 +2931,17 @@ class rcube_imap extends rcube_storage
else { else {
// unsubscribe non-existent folders, remove them from the list // unsubscribe non-existent folders, remove them from the list
if (!empty($result) && $name == '*') { if (!empty($result) && $name == '*') {
$existing = $this->list_folders($root, $name); $existing = $this->list_folders($root, $name);
$nonexisting = array_diff($result, $existing);
$result = array_diff($result, $nonexisting);
foreach ($nonexisting as $folder) { // Try to make sure the list of existing folders is not malformed,
$this->conn->unsubscribe($folder); // we don't want to unsubscribe existing folders on error
if (is_array($existing) && (!empty($root) || count($existing) > 1)) {
$nonexisting = array_diff($result, $existing);
$result = array_diff($result, $nonexisting);
foreach ($nonexisting as $folder) {
$this->conn->unsubscribe($folder);
}
} }
} }
} }

Loading…
Cancel
Save