php-imap
php-imap copied to clipboard
Folder Overview
Describe the bug
If you call $folder->overview("10:1") we got an error.
Expected behavior Inverted sequence of emails
Additional context Change code into ImapProtocol.php:
public function overview(string $sequence, $uid = IMAP::ST_UID): array {
$result = [];
list($from, $to) = explode(":", $sequence);
to:
public function overview(string $sequence, $uid = IMAP::ST_UID): array {
$result = [];
list($from, $to) = explode(":", $sequence);
if($to<$from){
list($to, $from) = explode(":", $sequence);
}
An improved i made is add flags and size.
foreach ($headers as $id => $raw_header) {
$result[$id] = (new Header($raw_header, false))->getAttributes();
$result[$id]["UID"]=$uids[$id];
}
$flags = $this->flags($ids, $uid);
foreach ($flags as $id => $flag) {
$result[$id]["flags"] = $flag;
}
$sizes = $this->sizes($ids, "RFC822", $uid);
foreach ($sizes as $id => $size) {
$result[$id]["size"] = $size;
}
I added a function for size:
public function sizes($uids, string $rfc = "RFC822", $uid = IMAP::ST_UID): array {
$result = $this->fetch(["$rfc.SIZE"], $uids, null, $uid);
return is_array($result) ? $result : [];
}
Hi @epocci , thanks for your report. I'm not sure if this is a bug or rather expected behavior. If we implement your suggested change, it might cause more confusion.
Please feel free to create a pull request to implement seize method, seems like a useful extension :) However I'm not sure about the code above, is that your example code or logic you want to implement?
Best regards & happy coding,
Please update to v5.1 and give it another try. If you are currently using an older version below v5.0, please read the breaking changes leading up to v5.1 before upgrading.
Best regards,