• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/agent.php
  • Класс: BitrixLandingAgent
  • Вызов: Agent::clearHistory
static function clearHistory(?int $days = null): string
{
	Rights::setGlobalOff();

	$newAgentName = __CLASS__ . '::' . __FUNCTION__ . '(' . ($days ?? '') . ');';

	$days = $days ?: (int) Manager::getOption('history_lifetime_days');
	$date = new DateTime();
	$date->add('-' . $days . ' days');

	$rows = HistoryTable::query()
		->setSelect(['ENTITY_ID', 'ENTITY_TYPE'])
		->setDistinct(true)
		->where('DATE_CREATE', '<', $date)
		->fetchAll()
	;
	foreach ($rows as $row)
	{
		$history = new History($row['ENTITY_ID'], $row['ENTITY_TYPE']);
		$history->clearOld($days);
	}

	return $newAgentName;
}