- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/lib/helper/mailbox.php
- Класс: BitrixMailHelperMailbox
- Вызов: Mailbox::dismissDeletedUidMessages
public function dismissDeletedUidMessages()
{
global $DB;
$startTime = time();
if (time() - $this->mailbox['SYNC_LOCK'] < static::getTimeout())
{
return false;
}
if ($this->isTimeQuotaExceeded())
{
return false;
}
$syncUnlock = $this->mailbox['SYNC_LOCK'];
$lockSql = sprintf(
'UPDATE b_mail_mailbox SET SYNC_LOCK = %u WHERE ID = %u AND (SYNC_LOCK IS NULL OR SYNC_LOCK < %u)',
$startTime, $this->mailbox['ID'], $startTime - static::getTimeout()
);
if ($DB->query($lockSql)->affectedRowsCount())
{
$this->mailbox['SYNC_LOCK'] = $startTime;
}
else
{
return false;
}
$minSyncTime = MailMailboxDirectory::getMinSyncTime($this->mailbox['ID']);
MailMailMessageUidTable::deleteList(
[
'=MAILBOX_ID' => $this->mailbox['ID'],
'>DELETE_TIME' => 0,
/*The values in the tables are still used to delete related items (example: attachments):*/
' $minSyncTime,
],
[],
static::MESSAGE_DELETION_LIMIT_AT_A_TIME
);
$unlockSql = sprintf(
"UPDATE b_mail_mailbox SET SYNC_LOCK = %d WHERE ID = %u AND SYNC_LOCK = %u",
$syncUnlock, $this->mailbox['ID'], $this->mailbox['SYNC_LOCK']
);
if ($DB->query($unlockSql)->affectedRowsCount())
{
$this->mailbox['SYNC_LOCK'] = $syncUnlock;
}
return true;
}