diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index ea4f6a1dd..1d88f0b1c 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -134,14 +134,30 @@ class TemplateHandler $source_template_mtime = filemtime($this->file); $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime; - - // get cached file + + // make compiled file if(!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime) { - FileHandler::writeFile($this->compiled_file, $this->parse()); + $buff = $this->parse(); + if(Rhymix\Framework\Storage::write($this->compiled_file, $buff) === false) + { + $tmpfilename = tempnam(sys_get_temp_dir(), 'rx-compiled'); + if($tmpfilename === false || Rhymix\Framework\Storage::write($tmpfilename, $buff) === false) + { + return 'Fatal Error : Cannot create temporary file. Please check permissions.'; + } + + $this->compiled_file = $tmpfilename; + } } - + $output = $this->_fetch($this->compiled_file); + + // delete tmpfile + if(isset($tmpfilename)) + { + Rhymix\Framework\Storage::delete($tmpfilename); + } if($__templatehandler_root_tpl == $this->file) { @@ -320,7 +336,7 @@ class TemplateHandler /** * fetch using ob_* function - * @param string $buff if buff is not null, eval it instead of including compiled template file + * @param string $filename compiled template file name * @return string */ private function _fetch($filename)