<commit_before><?php
/**
 * @package modules.comment.lib.services
 */
class comment_ModuleService extends ModuleBaseService
{
	/**
	 * Singleton
	 * @var comment_ModuleService
	 */
	private static $instance = null;

	/**
	 * @return comment_ModuleService
	 */
	public static function getInstance()
	{
		if (is_null(self::$instance))
		{
			self::$instance = self::getServiceClassInstance(get_class());
		}
		return self::$instance;
	}
	
	/**
	 * @param Integer $documentId
	 * @return f_persistentdocument_PersistentTreeNode
	 */
	public function getParentNodeForPermissions($documentId)
	{
		$document = DocumentHelper::getDocumentInstance($documentId);
		if ($document instanceof comment_persistentdocument_comment)
		{
			$targetId = $document->getTargetId();
			if ($targetId !== null)
			{
				$node = TreeService::getInstance()->getInstanceByDocumentId($targetId);
				if ($node === null)
				{
					$target = $document->getTarget();
					$moduleService = ModuleBaseService::getInstanceByModuleName($target->getPersistentModel()->getModuleName());
					if ($moduleService !== null)
					{
						$node = $moduleService->getParentNodeForPermissions($targetId);
					}
				}
				return $node;
			}
		}
		return null;
	}
	
	/**
	 * @return String
	 */
	public function getIp()
	{
		$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : null;
		if (f_util_StringUtils::isEmpty($ip))
		{
			$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
		}
		return $ip;
	}
}<commit_msg>[REFACTOR] call to request context<commit_after><?php
/**
 * @package modules.comment.lib.services
 */
class comment_ModuleService extends ModuleBaseService
{
	/**
	 * Singleton
	 * @var comment_ModuleService
	 */
	private static $instance = null;

	/**
	 * @return comment_ModuleService
	 */
	public static function getInstance()
	{
		if (is_null(self::$instance))
		{
			self::$instance = self::getServiceClassInstance(get_class());
		}
		return self::$instance;
	}
	
	/**
	 * @param Integer $documentId
	 * @return f_persistentdocument_PersistentTreeNode
	 */
	public function getParentNodeForPermissions($documentId)
	{
		$document = DocumentHelper::getDocumentInstance($documentId);
		if ($document instanceof comment_persistentdocument_comment)
		{
			$targetId = $document->getTargetId();
			if ($targetId !== null)
			{
				$node = TreeService::getInstance()->getInstanceByDocumentId($targetId);
				if ($node === null)
				{
					$target = $document->getTarget();
					$moduleService = ModuleBaseService::getInstanceByModuleName($target->getPersistentModel()->getModuleName());
					if ($moduleService !== null)
					{
						$node = $moduleService->getParentNodeForPermissions($targetId);
					}
				}
				return $node;
			}
		}
		return null;
	}
	
	/**
	 * @deprecated
	 * @return String
	 */
	public function getIp()
	{
		return RequestContext::getInstance()->getClientIp();
	}
}
{'fraction_non_alphanumeric': 0.14476843910806175, 'fraction_numerical': 0.0, 'mean_word_length': 4.197860962566845, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1195647', 'n_tokens_mistral': 1031, 'n_tokens_neox': 882, 'n_words': 155}