Make sure etag used on MessageList for #1515

This commit is contained in:
the-djmaze 2024-03-25 01:42:49 +01:00
parent 43622b50dc
commit c34f99dd6e
3 changed files with 11 additions and 13 deletions

View file

@ -214,8 +214,7 @@ trait Folders
// $oFolderInfo->SIZE = \max($oFolderInfo->SIZE, $oInfo->SIZE); // $oFolderInfo->SIZE = \max($oFolderInfo->SIZE, $oInfo->SIZE);
// $oFolderInfo->RECENT = \max(0, $oFolderInfo->RECENT, $oInfo->RECENT); // $oFolderInfo->RECENT = \max(0, $oFolderInfo->RECENT, $oInfo->RECENT);
$oFolderInfo->hasStatus = $oInfo->hasStatus; $oFolderInfo->hasStatus = $oInfo->hasStatus;
$oFolderInfo->generateETag($this); $oInfo = $oFolderInfo;
return $oFolderInfo;
} }
$oInfo->generateETag($this); $oInfo->generateETag($this);

View file

@ -96,6 +96,7 @@ trait Status
return; return;
} }
if (!isset($this->MESSAGES, $this->UIDNEXT)) { if (!isset($this->MESSAGES, $this->UIDNEXT)) {
\error_log("{$this->FullName} MESSAGES or UIDNEXT missing " . \print_r(\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),true));
return; return;
} }
$this->etag = \md5('FolderHash/'. \implode('-', [ $this->etag = \md5('FolderHash/'. \implode('-', [
@ -146,18 +147,17 @@ trait Status
$bResult = false; $bResult = false;
// OK untagged responses // OK untagged responses
if (\is_array($oResponse->OptionalResponse)) { if (\is_array($oResponse->OptionalResponse) && \count($oResponse->OptionalResponse) > 1) {
if (\count($oResponse->OptionalResponse) > 1) {
$bResult = $this->setStatusItem($oResponse->OptionalResponse[0], $oResponse->OptionalResponse[1]); $bResult = $this->setStatusItem($oResponse->OptionalResponse[0], $oResponse->OptionalResponse[1]);
} }
}
// untagged responses // untagged responses
else if (\count($oResponse->ResponseList) > 2) { else if (\count($oResponse->ResponseList) > 2) {
// LIST or STATUS command // LIST or STATUS command
if ('STATUS' === $oResponse->ResponseList[1] if ('STATUS' === $oResponse->ResponseList[1]
&& isset($oResponse->ResponseList[3]) && isset($oResponse->ResponseList[3])
&& \is_array($oResponse->ResponseList[3])) { && \is_array($oResponse->ResponseList[3])
) {
$c = \count($oResponse->ResponseList[3]); $c = \count($oResponse->ResponseList[3]);
for ($i = 0; $i < $c; $i += 2) { for ($i = 0; $i < $c; $i += 2) {
$bResult |= $this->setStatusItem( $bResult |= $this->setStatusItem(

View file

@ -621,21 +621,20 @@ class MailClient
/* /*
$oSearchCriterias->fuzzy = $oParams->bSearchFuzzy && $this->oImapClient->hasCapability('SEARCH=FUZZY'); $oSearchCriterias->fuzzy = $oParams->bSearchFuzzy && $this->oImapClient->hasCapability('SEARCH=FUZZY');
*/ */
$sSerializedHash = ''; $sSerializedHash = '';
$sSerializedLog = ''; $sSerializedLog = '';
if ($bUseCache) { if ($bUseCache && $oInfo->etag) {
$sSerializedHash = 'Get' $sSerializedHash = 'Get'
. ($bReturnUid ? 'UIDS/' : 'IDS/') . ($bReturnUid ? 'UIDS/' : 'IDS/')
. "{$oParams->sSort}/{$this->oImapClient->Hash()}/{$sFolderName}/{$oSearchCriterias}"; . "{$oParams->sSort}/{$this->oImapClient->Hash()}/{$sFolderName}/{$oSearchCriterias}";
$sSerializedLog = "\"{$sFolderName}\" / {$oParams->sSort} / {$oSearchCriterias}"; $sSerializedLog = "\"{$sFolderName}\" / {$oParams->sSort} / {$oSearchCriterias}";
$sSerialized = $oCacher->Get($sSerializedHash); $sSerialized = $oCacher->Get($sSerializedHash);
if (!empty($sSerialized)) { if (!empty($sSerialized)) {
$aSerialized = \json_decode($sSerialized, true); $aSerialized = \json_decode($sSerialized, true);
if (\is_array($aSerialized) && isset($aSerialized['FolderHash'], $aSerialized['Uids']) && if (\is_array($aSerialized)
$oInfo->etag === $aSerialized['FolderHash'] && && isset($aSerialized['FolderHash'], $aSerialized['Uids'])
\is_array($aSerialized['Uids']) && $oInfo->etag === $aSerialized['FolderHash']
&& \is_array($aSerialized['Uids'])
) { ) {
$this->logWrite('Get Serialized '.($bReturnUid?'UIDS':'IDS').' from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']'); $this->logWrite('Get Serialized '.($bReturnUid?'UIDS':'IDS').' from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']');
return $aSerialized['Uids']; return $aSerialized['Uids'];