- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/agent/recyclebin/recyclebinagent.php
- Класс: Bitrix\Crm\Agent\Recyclebin\RecyclebinAgent
- Вызов: RecyclebinAgent::removeExpiredEntities
static function removeExpiredEntities(int $ttl): void
{
$timestamp = time() + \CTimeZone::getOffset() - self::SECONDS_IN_DAY * $ttl;
$entityLimit = (int)Option::get('crm', 'recyclebin_agent_entity_limit', self::ENTITY_LIMIT);
$list = RecyclebinTable::getList([
'filter' => [
'MODULE_ID' => 'crm',
'<=TIMESTAMP' => DateTime::createFromTimestamp($timestamp),
],
'order' => ['TIMESTAMP' => 'ASC'],
'limit' => ($entityLimit > 0 ? $entityLimit : self::ENTITY_LIMIT),
]);
$timeLimit = (int)Option::get('crm', 'recyclebin_agent_time_limit', self::TIME_LIMIT);
$timeLimit = ($timeLimit > 0 ? $timeLimit : self::TIME_LIMIT);
$start = time();
foreach ($list as $item)
{
Recyclebin::remove($item['ID'], ['skipAdminRightsCheck' => true]);
if (time() - $start > $timeLimit)
{
return;
}
}
}