Protect MessageListThreadsMap()

This commit is contained in:
the-djmaze 2022-12-29 16:15:38 +01:00
parent 34543d5bf3
commit 6abcbd16c4

View file

@ -406,8 +406,9 @@ class MailClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function MessageListThreadsMap(string $sFolderName, string $sFolderHash, ?\MailSo\Cache\CacheClient $oCacher) : array protected function MessageListThreadsMap(MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher) : array
{ {
$sFolderName = $oMessageCollection->FolderName;
// $iThreadLimit = $this->oImapClient->Settings->thread_limit; // $iThreadLimit = $this->oImapClient->Settings->thread_limit;
$sSearchHash = ''; $sSearchHash = '';
@ -416,10 +417,11 @@ class MailClient
$sSearchHash = 'ALL'; $sSearchHash = 'ALL';
} }
$sSerializedHashKey = null;
if ($oCacher && $oCacher->IsInited()) { if ($oCacher && $oCacher->IsInited()) {
$sSerializedHashKey = $sSerializedHashKey =
"ThreadsMapSorted/{$sSearchHash}/{$sFolderName}/{$sFolderHash}"; "ThreadsMapSorted/{$sSearchHash}/{$sFolderName}/{$oMessageCollection->FolderHash}";
// "ThreadsMapSorted/{$sSearchHash}/{$iThreadLimit}/{$sFolderName}/{$sFolderHash}"; // "ThreadsMapSorted/{$sSearchHash}/{$iThreadLimit}/{$sFolderName}/{$oMessageCollection->FolderHash}";
if ($this->oLogger) { if ($this->oLogger) {
$this->oLogger->Write($sSerializedHashKey); $this->oLogger->Write($sSerializedHashKey);
@ -455,7 +457,7 @@ class MailClient
unset($oException); unset($oException);
} }
if ($oCacher && $oCacher->IsInited() && !empty($sSerializedHashKey)) { if (!empty($sSerializedHashKey)) {
$oCacher->Set($sSerializedHashKey, \json_encode(array( $oCacher->Set($sSerializedHashKey, \json_encode(array(
'ThreadsUids' => $aResult 'ThreadsUids' => $aResult
))); )));
@ -695,7 +697,7 @@ class MailClient
} else { } else {
$aUids = []; $aUids = [];
if ($bUseThreads) { if ($bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher); $aAllThreads = $this->MessageListThreadsMap($oMessageCollection, $oParams->oCacher);
$oMessageCollection->totalThreads = \count($aAllThreads); $oMessageCollection->totalThreads = \count($aAllThreads);
// $iThreadLimit = $this->oImapClient->Settings->thread_limit; // $iThreadLimit = $this->oImapClient->Settings->thread_limit;
if ($oParams->iThreadUid) { if ($oParams->iThreadUid) {