<commit_before><?

class Controller_assets_js_bundle_js extends Crunchbutton_Controller_AssetBundle {
	public function init() {

		$cacheid = 'crunchr-bundle-node-code'.$_REQUEST['v'].$_REQUEST['s'];
		
		$this->cacheId($cacheid);

		if (Cana::app()->cache()->cached($cacheid)) {
			$data = Cana::app()->cache()->read($cacheid);
		}

		if (!$data || !$data['content']) {

			if ($_REQUEST['s']) {
				switch ($_REQUEST['s']) {
					case 'app':
						$scripts = ['app'];
						break;
					case 'admin':
						$scripts = ['datepicker/eye','datepicker/layout','datepicker/utils','datepicker/datepicker','admin'];
						break;
					case 'cockpit':
						$scripts = [];
						break;
					default:
						$scripts = [];
						break;
				}
			}

			$src = c::view()->render('bundle/bundler.js');

			$doc = new DOMDocument('1.0');
			@$doc->loadHTML($src);

			foreach ($doc->getElementsByTagName('script') as $script) {
				if ($script->getAttribute('src')) {
					$files[] = c::config()->dirs->www.preg_replace('/^(.*)(\?.*)$/','\\1',$script->getAttribute('src'));
				} else {
					$code = $script->nodeValue;
					$tmp = tempnam('/tmp',$cacheid);
					$tmps[] = $tmp;
					file_put_contents($tmp,$code);
					$files[] = $tmp;
				}
			}
			
			if ($tmps) {
				foreach ($tmps as $tmp) {
					unlink($tmp);
				}
			}

			Cana::app()->cache()->write($cacheid, $data);
			$data = $this->serve($files, true);

		}

		if ($data['headers']) {
			foreach ($data['headers'] as $key => $header) {
				header($key.': '.$header);
			}
		}
		

		echo $data['content'];
		exit;
<commit_msg>Fixed asset crash issue<commit_after><?

class Controller_assets_js_bundle_js extends Crunchbutton_Controller_AssetBundle {
	public function init() {

		$cacheid = 'crunchr-bundle-node-code'.$_REQUEST['v'].$_REQUEST['s'];
		
		$this->cacheId($cacheid);

		if (Cana::app()->cache()->cached($cacheid)) {
			$data = Cana::app()->cache()->read($cacheid);
		}

		if (!$data || !$data['content']) {

			if ($_REQUEST['s']) {
				switch ($_REQUEST['s']) {
					case 'app':
						$scripts = ['app'];
						break;
					case 'admin':
						$scripts = ['datepicker/eye','datepicker/layout','datepicker/utils','datepicker/datepicker','admin'];
						break;
					case 'cockpit':
						$scripts = [];
						break;
					default:
						$scripts = [];
						break;
				}
			}

			$src = c::view()->render('bundle/bundler.js');

			$doc = new DOMDocument('1.0');
			@$doc->loadHTML($src);

			foreach ($doc->getElementsByTagName('script') as $script) {
				if ($script->getAttribute('src')) {
					$files[] = c::config()->dirs->www.preg_replace('/^(.*)(\?.*)$/','\\1',$script->getAttribute('src'));
				} else {
					$code = $script->nodeValue;
					$tmp = tempnam('/tmp',$cacheid);
					$tmps[] = $tmp;
					file_put_contents($tmp,$code);
					$files[] = $tmp;
				}
			}
			
			if ($tmps) {
				foreach ($tmps as $tmp) {
					unlink($tmp);
				}
			}

			Cana::app()->cache()->write($cacheid, $data);
			$data = $this->serve($files, true);

		}

		if ($data['headers']) {
			foreach ($data['headers'] as $key => $header) {
				if ($key == '_responseCode') {
					header($header);
				} else {
					header($key.': '.$header);
				}
			}
		}

		echo $data['content'];
		exit;

{'fraction_non_alphanumeric': 0.23360148514851486, 'fraction_numerical': 0.0018564356435643563, 'mean_word_length': 3.0161490683229815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5216826', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1105, 'n_words': 182}