<commit_before><?php
/**
 * Created by PhpStorm.
 * User: dimaninc
 * Date: 09.06.2017
 * Time: 11:28
 */

namespace diCore\Controller;

use diCore\Tool\Cache\Comment;
use diCore\Tool\Cache\Module;

class Cache extends \diBaseAdminController
{
	public static function rebuildTemplateAndContentCache()
	{
		$Z = new \diCurrentCMS();
		$Z->init_tpl();
		$Z->getTpl()->rebuild_cache();
		$Z->build_content_table_cache();
	}

	public function rebuildAction()
	{
		self::rebuildTemplateAndContentCache();
		\diTwig::flushCache();

		$this->redirect();
	}

	public function updateCommentsCountsAction()
	{
		$errors = Comment::updateCounts();

		if (!$errors) {
			$this->redirect();
		}

		return $errors ?: null;
	}

	public function updateModuleAction()
	{
		try {
			$MC = Module::basicCreate();

			if ($cacheModuleId = $this->param(0, 0)) {
				$MC->rebuild($cacheModuleId);
			} else {
				$MC->rebuildAll();
			}
		} catch (\Exception $e) {
			return [
				'done' => false,
				'error' => $e->getMessage(),
			];
		}

		return [
			'done' => true,
		];
	}
}<commit_msg>Cache controller: id fix<commit_after><?php
/**
 * Created by PhpStorm.
 * User: dimaninc
 * Date: 09.06.2017
 * Time: 11:28
 */

namespace diCore\Controller;

use diCore\Tool\Cache\Comment;
use diCore\Tool\Cache\Module;

class Cache extends \diBaseAdminController
{
	public static function rebuildTemplateAndContentCache()
	{
		$Z = new \diCurrentCMS();
		$Z->init_tpl();
		$Z->getTpl()->rebuild_cache();
		$Z->build_content_table_cache();
	}

	public function rebuildAction()
	{
		self::rebuildTemplateAndContentCache();
		\diTwig::flushCache();

		$this->redirect();
	}

	public function updateCommentsCountsAction()
	{
		$errors = Comment::updateCounts();

		if (!$errors) {
			$this->redirect();
		}

		return $errors ?: null;
	}

	public function updateModuleAction()
	{
		try {
			$MC = Module::basicCreate();
			$cacheModuleId = $this->param(0, \diRequest::get('id', 0));

			if ($cacheModuleId) {
				$MC->rebuild($cacheModuleId);
			} else {
				$MC->rebuildAll();
			}
		} catch (\Exception $e) {
			return [
				'done' => false,
				'error' => $e->getMessage(),
			];
		}

		return [
			'done' => true,
		];
	}
}
{'fraction_non_alphanumeric': 0.1744874715261959, 'fraction_numerical': 0.01275626423690205, 'mean_word_length': 3.594142259414226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4607923', 'n_tokens_mistral': 908, 'n_tokens_neox': 780, 'n_words': 147}