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->RECENT = \max(0, $oFolderInfo->RECENT, $oInfo->RECENT);
$oFolderInfo->hasStatus = $oInfo->hasStatus;
$oFolderInfo->generateETag($this);
return $oFolderInfo;
$oInfo = $oFolderInfo;
}
$oInfo->generateETag($this);

View file

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

View file

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