From: <pdo...@us...> - 2022-05-22 15:44:45
|
Revision: 14950 http://sourceforge.net/p/squirrelmail/code/14950 Author: pdontthink Date: 2022-05-22 15:44:41 +0000 (Sun, 22 May 2022) Log Message: ----------- Fix bug where could not toggle flag (delete, etc) a single message Modified Paths: -------------- trunk/squirrelmail/functions/imap_messages.php Modified: trunk/squirrelmail/functions/imap_messages.php =================================================================== --- trunk/squirrelmail/functions/imap_messages.php 2022-04-25 21:28:55 UTC (rev 14949) +++ trunk/squirrelmail/functions/imap_messages.php 2022-05-22 15:44:41 UTC (rev 14950) @@ -17,7 +17,8 @@ /** * Copy a set of messages ($id) to another mailbox ($mailbox) * @param int $imap_stream The resource ID for the IMAP socket - * @param string $id The list of messages to copy + * @param mixed $id Normally an array which is a list with message UIDs to be copied + * or a string range such as "1:*" or a simple integer * @param string $mailbox The destination to copy to * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response * @return bool If the copy completed without errors @@ -59,7 +60,8 @@ * Deletes a message and move it to trash or expunge the mailbox * @param resource imap connection * @param string $mailbox mailbox, used for checking if it concerns the trash_folder - * @param array $id list with uid's + * @param mixed $id Normally an array which is a list with message UIDs to be deleted + * or a string range such as "1:*" or a simple integer * @param bool $bypass_trash (since 1.5.0) skip copy to trash * @return array $aMessageList array with messages containing the new flags and UID @see parseFetch * @since 1.4.0 @@ -83,7 +85,7 @@ * Set a flag on the provided uid list * @param resource imap connection * @param mixed $id Normally an array which is a list with message UIDs to be flagged - * or a string range such as "1:*" + * or a string range such as "1:*" or a simple integer * @param string $flag Flags to set/unset flags can be i.e.'\Seen', '\Answered', '\Seen \Answered' * @param bool $set add (true) or remove (false) the provided flag * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response @@ -93,11 +95,15 @@ $msgs_id = sqimap_message_list_squisher($id); $set_string = ($set ? '+' : '-'); + /* + * We need to return the data in the same order as the caller supplied + * in $id, but IMAP servers are free to return responses in + * whatever order they wish... So we need to re-sort manually + */ $aMessageList = array(); - // TODO: There doesn't seem to be a reason to set up $aMessageList anyway because an empty array for each message doesn't add anything to the parseFetch() return value, so this code block could be simply deleted: - if (!is_string($id)) { - for ($i=0; $i<sizeof($id); $i++) { - $aMessageList["$id[$i]"] = array(); + if (is_array($id)) { + for ($i=0; $i<count($id); $i++) { + $aMessageList[$id[$i]] = array(); } } @@ -607,7 +613,7 @@ */ if ($bUidFetch) { for ($i = 0; $i < sizeof($msg_list); $i++) { - $aMessageList["$msg_list[$i]"] = array(); + $aMessageList[$msg_list[$i]] = array(); } } } else { @@ -638,8 +644,10 @@ /** * Parses a fetch response, currently it can hande FLAGS, HEADERS, RFC822.SIZE, INTERNALDATE and UID * @param array $aResponse Imap response - * @param array $aMessageList Placeholder array for results. The keys of the - * placeholder array should be the UID so we can reconstruct the order. + * @param array $aMessageList Placeholder array for results. The keys of this + * placeholder array should be the UID so we can + * reconstruct the order (OPTIONAL; this array will + * be built for the return value fresh if not given) * @return array $aMessageList associative array with messages. Key is the UID, value is an associative array * @author Marc Groot Koerkamp */ @@ -794,6 +802,7 @@ $msgi = "$unique_id"; $aMsg['UID'] = $unique_id; } else { +//FIXME: under what circumstances does this happen? We can't use an empty string as an array index in the line just below, so we need to use something else here $msgi = ''; } $aMessageList[$msgi] = $aMsg; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |