<commit_before><?php
class task_PublishTask extends task_SimpleSystemTask  
{
	/**
	 * @see task_SimpleSystemTask::execute()
	 *
	 */
	protected function execute()
	{
		$end = date_Calendar::now()->toString();
		
		$start = $this->plannedTask->getLastrundate();
		if ($start == null)
		{
			$start = date_Calendar::getInstance($end)->add(date_Calendar::MINUTE, -5)->toString();
		}
		else
		{
			$start = date_Calendar::getInstance($start)->add(date_Calendar::MINUTE, -1)->toString();
		}
		
		$documentsArray = array_chunk($this->getDocumentIdsToProcess($start, $end), 500);
		$script = 'framework/listener/publishDocumentsBatch.php';
		foreach ($documentsArray as $chunk)
		{
			$result = f_util_System::execHTTPScript($script, $chunk);
			// Log fatal errors...
			if ($result != '1')
			{
				Framework::error(__METHOD__ . ' ' . $script . ' unexpected result: "' . $result . '"');
			}
		}
		
		$this->plannedTask->reSchedule(date_Calendar::getInstance()->add(date_Calendar::MINUTE, +10));
	}
	
	private function getDocumentIdsToProcess($start, $end)
	{
		if (Framework::isInfoEnabled())
		{
			Framework::info(__METHOD__ ."($start, $end)");
		}
		$toProcess = array();
		$compiledFilePath = f_util_FileUtils::buildChangeBuildPath('publishListenerInfos.ser');
		if (file_exists($compiledFilePath))
		{
			$models = unserialize(file_get_contents($compiledFilePath));
			$rc = RequestContext::getInstance();
			foreach ($models as $modelName => $langs) 
			{
				foreach ($langs as $lang)
				{
					try
					{<commit_msg>[FIX] Fix tasks error logging.<commit_after><?php
class task_PublishTask extends task_SimpleSystemTask  
{
	/**
	 * @see task_SimpleSystemTask::execute()
	 *
	 */
	protected function execute()
	{
		$end = date_Calendar::now()->toString();
		
		$start = $this->plannedTask->getLastrundate();
		if ($start == null)
		{
			$start = date_Calendar::getInstance($end)->add(date_Calendar::MINUTE, -5)->toString();
		}
		else
		{
			$start = date_Calendar::getInstance($start)->add(date_Calendar::MINUTE, -1)->toString();
		}
		
		$documentsArray = array_chunk($this->getDocumentIdsToProcess($start, $end), 500);
		$script = 'framework/listener/publishDocumentsBatch.php';
		foreach ($documentsArray as $chunk)
		{
			$result = f_util_System::execHTTPScript($script, $chunk);
			// Log fatal errors...
			if ($result != 'OK')
			{
				Framework::error(__METHOD__ . ' ' . $script . ' unexpected result: "' . $result . '"');
			}
		}
		
		$this->plannedTask->reSchedule(date_Calendar::getInstance()->add(date_Calendar::MINUTE, +10));
	}
	
	private function getDocumentIdsToProcess($start, $end)
	{
		if (Framework::isInfoEnabled())
		{
			Framework::info(__METHOD__ ."($start, $end)");
		}
		$toProcess = array();
		$compiledFilePath = f_util_FileUtils::buildChangeBuildPath('publishListenerInfos.ser');
		if (file_exists($compiledFilePath))
		{
			$models = unserialize(file_get_contents($compiledFilePath));
			$rc = RequestContext::getInstance();
			foreach ($models as $modelName => $langs) 
			{
				foreach ($langs as $lang)
				{
					try
					{
{'fraction_non_alphanumeric': 0.17188519243313763, 'fraction_numerical': 0.004892367906066536, 'mean_word_length': 4.399647887323944, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6580316', 'n_tokens_mistral': 1137, 'n_tokens_neox': 965, 'n_words': 162}