• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/lib/helper/mailbox.php
  • Класс: BitrixMailHelperMailbox
  • Вызов: Mailbox::cleanup
public function cleanup()
{
	do
	{
		$res = MailInternalsMessageDeleteQueueTable::getList(array(
			'runtime' => array(
				new ORMFieldsRelationsReference(
					'MESSAGE_UID',
					'BitrixMailMailMessageUidTable',
					array(
						'=this.MAILBOX_ID' => 'ref.MAILBOX_ID',
						'=this.MESSAGE_ID' => 'ref.MESSAGE_ID',
					)
				),
			),
			'select' => array('MESSAGE_ID', 'UID' => 'MESSAGE_UID.ID'),
			'filter' => array(
				'=MAILBOX_ID' => $this->mailbox['ID'],
			),
			'limit' => 100,
		));

		$count = 0;
		while ($item = $res->fetch())
		{
			$count++;

			if (empty($item['UID']))
			{
				CMailMessage::delete($item['MESSAGE_ID']);
			}

			MailInternalsMessageDeleteQueueTable::deleteList(array(
				'=MAILBOX_ID' => $this->mailbox['ID'],
				'=MESSAGE_ID' => $item['MESSAGE_ID'],
			));

			if ($this->isTimeQuotaExceeded() || time() - $this->checkpoint > 60)
			{
				return false;
			}
		}
	}
	while ($count > 0);

	return true;
}