• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/lib/comments/feed.php
  • Класс: BitrixForumCommentsFeed
  • Вызов: Feed::moveEventCommentsToNewXmlId
public function moveEventCommentsToNewXmlId(string $newEntityXmlId): bool
{
	if (is_null($this->topic))
	{
		return true;
	}

	$forumId = $this->getForum()['ID'];

	$rows = BitrixForumMessageTable::query()
		->setSelect(['ID'])
		->where('FORUM_ID', $forumId)
		->where('TOPIC_ID', $this->topic['ID']);

	$comments = $rows->fetchAll();
	if (empty($comments))
	{
		return true;
	}

	$newFeed = new BitrixForumCommentsFeed($forumId, [
		'type' => 'EV',
		'id' => $this->getEntity()->getId(),
		'xml_id' => $newEntityXmlId,
	]);

	if (!$newFeed->checkTopic())
	{
		return false;
	}

	$newTopicId = $newFeed->getTopic()['ID'];
	$commentsIds = array_map('intval', array_column($comments, 'ID'));
	BitrixForumMessageTable::updateMulti($commentsIds, [
		'TOPIC_ID' => $newTopicId,
	]);

	return true;
}