• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/lib/update/livefeedconvertservicemessage.php
  • Класс: BitrixForumUpdateLivefeedConvertServiceMessage
  • Вызов: LivefeedConvertServiceMessage::replaceServiceField
public function replaceServiceField($lastId)
{
	$comments = $this->getCommentsCollection([
		"!SERVICE_TYPE" => null,
		"SERVICE_DATA" => null
	], $lastId);
	$rowsCount = $comments->count();

	$lastId = 0;
	if ($rowsCount > 0)
	{
		$currentLang = MainLocalizationLoc::getCurrentLang();
		$defaultLanguage= MainLocalizationLoc::getDefaultLang(LANGUAGE_ID);
		if ($currentLang !== $defaultLanguage)
		{
			MainLocalizationLoc::setCurrentLang($defaultLanguage);
		}
		while ($comment = $comments->current())
		{
			$serviceData = $comment->getPostMessage();
			if ($handler = ForumCommentsServiceManager::find([
				"SERVICE_TYPE" => $comment->getServiceType()
			]))
			{
				$postMessage = $handler->getText($serviceData);
				if ($postMessage !== '')
				{
					$comment->setPostMessage($postMessage);
					$comment->setServiceData(is_null($serviceData) ? Json::encode([]) : $serviceData);
					$comment->save();
				}
			}
			$lastId = $comment->getId();
			$comments->next();
		}
		if ($currentLang !== $defaultLanguage)
		{
			MainLocalizationLoc::setCurrentLang($currentLang);
		}
	}
	return $rowsCount < static::MESSAGE_LIMIT ? self::FINISH_EXECUTION : $lastId;
}