Bugfix: undefined $this->oImapResponse->ResponseList

This commit is contained in:
the-djmaze 2022-12-13 14:06:47 +01:00
parent f8f8cd0124
commit 21eaf88fd9
2 changed files with 11 additions and 26 deletions

View file

@ -17,26 +17,18 @@ namespace MailSo\Imap;
*/ */
class FetchResponse class FetchResponse
{ {
/** public Response $oImapResponse;
* @var \MailSo\Imap\Response
*/
private $oImapResponse;
/** private ?array $aEnvelopeCache = null;
* @var array|null
*/
private $aEnvelopeCache;
function __construct(Response $oImapResponse) function __construct(Response $oImapResponse)
{ {
$this->oImapResponse = $oImapResponse; $this->oImapResponse = $oImapResponse;
$this->aEnvelopeCache = null;
} }
public function GetEnvelope(bool $bForce = false) : ?array public function GetEnvelope(bool $bForce = false) : ?array
{ {
if (null === $this->aEnvelopeCache || $bForce) if (null === $this->aEnvelopeCache || $bForce) {
{
$this->aEnvelopeCache = $this->GetFetchValue(Enumerations\FetchType::ENVELOPE); $this->aEnvelopeCache = $this->GetFetchValue(Enumerations\FetchType::ENVELOPE);
} }
return $this->aEnvelopeCache; return $this->aEnvelopeCache;
@ -54,13 +46,10 @@ class FetchResponse
{ {
$oResult = null; $oResult = null;
$aEmails = $this->GetFetchEnvelopeValue($iIndex); $aEmails = $this->GetFetchEnvelopeValue($iIndex);
if (\is_array($aEmails) && \count($aEmails)) if (\is_array($aEmails) && \count($aEmails)) {
{
$oResult = new \MailSo\Mime\EmailCollection; $oResult = new \MailSo\Mime\EmailCollection;
foreach ($aEmails as $aEmailItem) foreach ($aEmails as $aEmailItem) {
{ if (\is_array($aEmailItem) && 4 === \count($aEmailItem)) {
if (\is_array($aEmailItem) && 4 === \count($aEmailItem))
{
$sDisplayName = \MailSo\Base\Utils::DecodeHeaderValue( $sDisplayName = \MailSo\Base\Utils::DecodeHeaderValue(
self::findEnvelopeIndex($aEmailItem, 0, ''), $sParentCharset); self::findEnvelopeIndex($aEmailItem, 0, ''), $sParentCharset);
@ -70,8 +59,7 @@ class FetchResponse
$sLocalPart = self::findEnvelopeIndex($aEmailItem, 2, ''); $sLocalPart = self::findEnvelopeIndex($aEmailItem, 2, '');
$sDomainPart = self::findEnvelopeIndex($aEmailItem, 3, ''); $sDomainPart = self::findEnvelopeIndex($aEmailItem, 3, '');
if (\strlen($sLocalPart) && \strlen($sDomainPart)) if (\strlen($sLocalPart) && \strlen($sDomainPart)) {
{
$oResult->append( $oResult->append(
new \MailSo\Mime\Email($sLocalPart.'@'.$sDomainPart, $sDisplayName) new \MailSo\Mime\Email($sLocalPart.'@'.$sDomainPart, $sDisplayName)
); );
@ -122,12 +110,9 @@ class FetchResponse
{ {
$bNextIsValue = false; $bNextIsValue = false;
if (isset($this->oImapResponse->ResponseList[3]) && \is_array($this->oImapResponse->ResponseList[3])) if (isset($this->oImapResponse->ResponseList[3]) && \is_array($this->oImapResponse->ResponseList[3])) {
{ foreach ($this->oImapResponse->ResponseList[3] as $mItem) {
foreach ($this->oImapResponse->ResponseList[3] as $mItem) if ($bNextIsValue) {
{
if ($bNextIsValue)
{
return (string) $mItem; return (string) $mItem;
} }

View file

@ -611,7 +611,7 @@ class MailClient
foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ $oFetchResponseItem) { foreach ($aFetchResponse as /* @var $oFetchResponseItem \MailSo\Imap\FetchResponse */ $oFetchResponseItem) {
$id = $oRange->UID $id = $oRange->UID
? $oFetchResponseItem->GetFetchValue(FetchType::UID) ? $oFetchResponseItem->GetFetchValue(FetchType::UID)
: $this->oImapResponse->ResponseList[1]; : $oFetchResponseItem->oImapResponse->ResponseList[1];
$aCollection[$id] = Message::NewFetchResponseInstance($oMessageCollection->FolderName, $oFetchResponseItem); $aCollection[$id] = Message::NewFetchResponseInstance($oMessageCollection->FolderName, $oFetchResponseItem);
} }
$oMessageCollection->exchangeArray(\array_values(\array_filter($aCollection))); $oMessageCollection->exchangeArray(\array_values(\array_filter($aCollection)));