From 96efd44239a2ce740389f761d8b82267a8066e56 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 18 Mar 2009 13:44:04 -0600 Subject: [PATCH] Really return message list in expunge() for Socket driver. --- framework/Imap_Client/lib/Horde/Imap/Client/Socket.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; } } -- 2.11.0