Bugfix: Delete folder failed

This commit is contained in:
the-djmaze 2022-01-12 11:13:00 +01:00
parent 9fea092c43
commit a568c3f4f8
2 changed files with 20 additions and 22 deletions

View file

@ -16,6 +16,7 @@ use MailSo\Imap\Folder;
use MailSo\Imap\FolderInformation; use MailSo\Imap\FolderInformation;
use MailSo\Imap\SequenceSet; use MailSo\Imap\SequenceSet;
use MailSo\Imap\Enumerations\FolderStatus; use MailSo\Imap\Enumerations\FolderStatus;
use MailSo\Imap\Enumerations\FolderResponseStatus;
/** /**
* @category MailSo * @category MailSo
@ -93,11 +94,23 @@ trait Folders
* @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception
*/ */
public function FolderStatus(string $sFolderName, array $aStatusItems) : ?array public function FolderStatus(string $sFolderName) : FolderInformation
{ {
if (!\count($aStatusItems)) { $aStatusItems = array(
return null; FolderResponseStatus::MESSAGES,
FolderResponseStatus::UNSEEN,
FolderResponseStatus::UIDNEXT
);
if ($this->IsSupported('CONDSTORE')) {
$aStatusItems[] = FolderResponseStatus::HIGHESTMODSEQ;
} }
if ($this->IsSupported('APPENDLIMIT')) {
$aStatusItems[] = FolderResponseStatus::APPENDLIMIT;
}
if ($this->IsSupported('OBJECTID')) {
$aStatusItems[] = FolderResponseStatus::MAILBOXID;
}
$oFolderInfo = $this->oCurrentFolderInfo; $oFolderInfo = $this->oCurrentFolderInfo;
$bReselect = false; $bReselect = false;
$bWritable = false; $bWritable = false;
@ -129,7 +142,8 @@ trait Folders
if ($bReselect) { if ($bReselect) {
$this->selectOrExamineFolder($sFolderName, $bWritable, false); $this->selectOrExamineFolder($sFolderName, $bWritable, false);
} }
return $oInfo->getStatusItems();
return $oInfo;
} }
/** /**

View file

@ -413,23 +413,7 @@ class MailClient
protected function initFolderValues(string $sFolderName) : array protected function initFolderValues(string $sFolderName) : array
{ {
$aTypes = array( $aFolderStatus = $this->oImapClient->FolderStatus($sFolderName)->getStatusItems();
FolderResponseStatus::MESSAGES,
FolderResponseStatus::UNSEEN,
FolderResponseStatus::UIDNEXT
);
if ($this->oImapClient->IsSupported('CONDSTORE')) {
$aTypes[] = FolderResponseStatus::HIGHESTMODSEQ;
}
if ($this->oImapClient->IsSupported('APPENDLIMIT')) {
$aTypes[] = FolderResponseStatus::APPENDLIMIT;
}
if ($this->oImapClient->IsSupported('OBJECTID')) {
$aTypes[] = FolderResponseStatus::MAILBOXID;
}
$aFolderStatus = $this->oImapClient->FolderStatus($sFolderName, $aTypes);
return [ return [
\max(0, $aFolderStatus[FolderResponseStatus::MESSAGES] ?: 0), \max(0, $aFolderStatus[FolderResponseStatus::MESSAGES] ?: 0),
@ -1246,7 +1230,7 @@ class MailClient
throw new \MailSo\Base\Exceptions\InvalidArgumentException; throw new \MailSo\Base\Exceptions\InvalidArgumentException;
} }
if ($this->IsSupported('IMAP4rev2')) { if ($this->oImapClient->IsSupported('IMAP4rev2')) {
$oInfo = $this->oImapClient->FolderExamine($sFolderFullName); $oInfo = $this->oImapClient->FolderExamine($sFolderFullName);
} else { } else {
$oInfo = $this->oImapClient->FolderStatus($sFolderFullName); $oInfo = $this->oImapClient->FolderStatus($sFolderFullName);