A solution for #365

This commit is contained in:
the-djmaze 2022-05-08 11:19:25 +02:00
parent fb95174f67
commit 06c0666b93
4 changed files with 16 additions and 13 deletions

View file

@ -105,9 +105,6 @@ class Folder
return 'INBOX' === \strtoupper($this->sFullName) || \in_array('\\inbox', $this->aFlagsLowerCase); return 'INBOX' === \strtoupper($this->sFullName) || \in_array('\\inbox', $this->aFlagsLowerCase);
} }
/**
* @param mixed $mData
*/
public function SetMetadata(string $sName, string $sData) : void public function SetMetadata(string $sName, string $sData) : void
{ {
$this->aMetadata[$sName] = $sData; $this->aMetadata[$sName] = $sData;
@ -118,17 +115,11 @@ class Folder
$this->aMetadata = $aMetadata; $this->aMetadata = $aMetadata;
} }
/**
* @return mixed
*/
public function GetMetadata(string $sName) : ?string public function GetMetadata(string $sName) : ?string
{ {
return isset($this->aMetadata[$sName]) ? $this->aMetadata[$sName] : null; return isset($this->aMetadata[$sName]) ? $this->aMetadata[$sName] : null;
} }
/**
* @return array
*/
public function Metadata() : array public function Metadata() : array
{ {
return $this->aMetadata; return $this->aMetadata;

View file

@ -67,6 +67,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @var bool * @var bool
*/ */
public $__FORCE_SELECT_ON_EXAMINE__ = false; public $__FORCE_SELECT_ON_EXAMINE__ = false;
public $__DISABLE_METADATA = false;
/** /**
* @var bool * @var bool
@ -92,7 +93,7 @@ class ImapClient extends \MailSo\Net\NetClient
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned, $sClientCert); parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned, $sClientCert);
$this->aCapabilityItems = $this->getResponse('*')->getCapabilityResult(); $this->setCapabilities($this->getResponse('*'));
if ($this->IsSupported('STARTTLS') && \MailSo\Net\Enumerations\ConnectionSecurityType::UseStartTLS($this->iSecurityType)) if ($this->IsSupported('STARTTLS') && \MailSo\Net\Enumerations\ConnectionSecurityType::UseStartTLS($this->iSecurityType))
{ {
@ -225,7 +226,7 @@ class ImapClient extends \MailSo\Net\NetClient
)); ));
} }
$this->aCapabilityItems = $oResponse->getCapabilityResult(); $this->setCapabilities($oResponse);
if (\strlen($sProxyAuthUser)) if (\strlen($sProxyAuthUser))
{ {
@ -285,12 +286,21 @@ class ImapClient extends \MailSo\Net\NetClient
public function Capability() : ?array public function Capability() : ?array
{ {
if (!$this->aCapabilityItems) { if (!$this->aCapabilityItems) {
$this->aCapabilityItems = $this->SendRequestGetResponse('CAPABILITY') $this->setCapabilities($this->SendRequestGetResponse('CAPABILITY'));
->getCapabilityResult();
} }
return $this->aCapabilityItems; return $this->aCapabilityItems;
} }
private function setCapabilities(ResponseCollection $oResponseCollection) : void
{
$aList = $oResponseCollection->getCapabilityResult();
if ($aList && $this->__DISABLE_METADATA) {
// Issue #365: Many folders on Cyrus IMAP breaks login
$aList = \array_diff($aList, ['METADATA']);
}
$this->aCapabilityItems = $aList;
}
/** /**
* Test support for things like: * Test support for things like:
* IMAP4rev1 IMAP4rev2 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY * IMAP4rev1 IMAP4rev2 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY

View file

@ -1234,6 +1234,7 @@ class Actions
} }
$this->MailClient()->ImapClient()->__FORCE_SELECT_ON_EXAMINE__ = !!$this->oConfig->Get('labs', 'use_imap_force_selection'); $this->MailClient()->ImapClient()->__FORCE_SELECT_ON_EXAMINE__ = !!$this->oConfig->Get('labs', 'use_imap_force_selection');
$this->MailClient()->ImapClient()->__DISABLE_METADATA = !!$this->oConfig->Get('labs', 'imap_disable_metadata');
} }
return $oAccount; return $oAccount;

View file

@ -369,6 +369,7 @@ Enables caching in the system'),
'imap_show_login_alert' => array(true), 'imap_show_login_alert' => array(true),
'imap_use_list_status' => array(true), 'imap_use_list_status' => array(true),
'imap_timeout' => array(300), 'imap_timeout' => array(300),
'imap_disable_metadata' => array(false),
'smtp_show_server_errors' => array(false), 'smtp_show_server_errors' => array(false),
'smtp_timeout' => array(60), 'smtp_timeout' => array(60),
'sieve_auth_plain_initial' => array(true), 'sieve_auth_plain_initial' => array(true),