Make IMAP LIST-STATUS extension optional so you can turn it off on slow servers.

See application.ini `imap_use_list_status`
This commit is contained in:
djmaze 2021-10-27 22:44:24 +02:00
parent 68fc40e911
commit 9fbde56e01
4 changed files with 11 additions and 5 deletions

View file

@ -254,6 +254,7 @@ imap_folder_list_limit = 200
imap_show_login_alert = On imap_show_login_alert = On
imap_use_auth_plain = On imap_use_auth_plain = On
imap_use_auth_cram_md5 = Off imap_use_auth_cram_md5 = Off
imap_use_list_status = On
smtp_show_server_errors = Off smtp_show_server_errors = Off
smtp_use_auth_plain = On smtp_use_auth_plain = On
smtp_use_auth_cram_md5 = Off smtp_use_auth_cram_md5 = Off

View file

@ -1911,7 +1911,7 @@ class MailClient
return $aMailFoldersHelper; return $aMailFoldersHelper;
} }
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : ?FolderCollection public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus, int $iOptimizationLimit, bool $bUseListStatus) : ?FolderCollection
{ {
$aImapSubscribedFoldersHelper = null; $aImapSubscribedFoldersHelper = null;
if ($this->oImapClient->IsSupported('LIST-EXTENDED')) { if ($this->oImapClient->IsSupported('LIST-EXTENDED')) {
@ -1933,8 +1933,11 @@ class MailClient
} }
} }
// $aFolders = $this->oImapClient->FolderList($sParent, $sListPattern); $bUseListStatus = $bUseListStatus && $this->oImapClient->IsSupported('LIST-STATUS');
$aFolders = $this->oImapClient->FolderStatusList($sParent, $sListPattern);
$aFolders = $bUseListStatus
? $this->oImapClient->FolderStatusList($sParent, $sListPattern)
: $this->oImapClient->FolderList($sParent, $sListPattern);
if (!$aFolders) { if (!$aFolders) {
return null; return null;
} }
@ -1958,7 +1961,7 @@ class MailClient
$oFolderCollection->IsMetadataSupported = $this->oImapClient->IsSupported('METADATA'); $oFolderCollection->IsMetadataSupported = $this->oImapClient->IsSupported('METADATA');
$oFolderCollection->IsThreadsSupported = $this->IsThreadsSupported(); $oFolderCollection->IsThreadsSupported = $this->IsThreadsSupported();
$oFolderCollection->IsSortSupported = $this->oImapClient->IsSupported('SORT'); $oFolderCollection->IsSortSupported = $this->oImapClient->IsSupported('SORT');
$oFolderCollection->IsListStatusSupported = $this->oImapClient->IsSupported('LIST-STATUS'); $oFolderCollection->IsListStatusSupported = $bUseListStatus;
$oFolderCollection->Optimized = $iCount !== \count($aMailFoldersHelper); $oFolderCollection->Optimized = $iCount !== \count($aMailFoldersHelper);
$aSortedByLenImapFolders = array(); $aSortedByLenImapFolders = array();

View file

@ -14,7 +14,8 @@ trait Folders
{ {
return $this->MailClient()->Folders('', '*', return $this->MailClient()->Folders('', '*',
$HideUnsubscribed, $HideUnsubscribed,
(int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200) (int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200),
(bool) $this->Config()->Get('labs', 'imap_use_list_status', true)
); );
} }

View file

@ -338,6 +338,7 @@ Enables caching in the system'),
'imap_show_login_alert' => array(true), 'imap_show_login_alert' => array(true),
'imap_use_auth_plain' => array(true), 'imap_use_auth_plain' => array(true),
'imap_use_auth_cram_md5' => array(false), 'imap_use_auth_cram_md5' => array(false),
'imap_use_list_status' => array(true),
'smtp_show_server_errors' => array(false), 'smtp_show_server_errors' => array(false),
'smtp_use_auth_plain' => array(true), 'smtp_use_auth_plain' => array(true),
'smtp_use_auth_cram_md5' => array(false), 'smtp_use_auth_cram_md5' => array(false),