Merge pull request #438 from conory/develop

캐시 파일을 쓸 수 없을때 화면 출력이 되지않는 문제 수정
This commit is contained in:
CONORY 2016-04-13 13:25:05 +09:00
commit f89262c87a

View file

@ -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)