From: Michael M Slusarz Date: Wed, 18 Mar 2009 19:44:04 +0000 (-0600) Subject: Really return message list in expunge() for Socket driver. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=96efd44239a2ce740389f761d8b82267a8066e56;p=horde.git Really return message list in expunge() for Socket driver. --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index ca03445e0..74aecc102 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -1378,10 +1378,19 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $i = count($tmp['vanished']); $expunged = $tmp['vanished']; } elseif (!empty($tmp['expunge'])) { - $i = 0; + $i = $last = 0; $t = $s_res['sort']; + + /* Expunge responses can come in any order. Thus, we need to + * reindex anytime we have an index that appears equal to or + * after a previously seen index. If an IMAP server is smart, + * it will expunge in reverse order instead. */ foreach ($tmp['expunge'] as $val) { - $expunged[] = $t[$val - 1 + $i++]; + if ($i++ && ($val >= $last)) { + $t = array_values($t); + } + $expunged[] = $t[$val - 1]; + $last = $val; } }