- bugfix config files got recompiled on each request

This commit is contained in:
Uwe Tews
2015-07-20 03:15:45 +02:00
parent 61253c1999
commit 3e54c268ab
3 changed files with 15 additions and 6 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.28-dev===== (xx.xx.2015)
20.07.2015
- bugfix config files got recompiled on each request
12.07.2015
- optimize {extends} compilation

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.28-dev/28';
const SMARTY_VERSION = '3.1.28-dev/29';
/**
* define variable scopes
@@ -1419,7 +1419,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* Compile all config files
*
* @param string $extension file extension
* @param bool $force_compile force all to recompile
* @param bool $force_compile force all to recompile<
* @param int $time_limit
* @param int $max_errors
*

View File

@@ -30,6 +30,7 @@ class Smarty_Internal_Config_File_Compiler
* @var string
*/
public $parser_class;
/**
* Lexer object
*
@@ -100,12 +101,15 @@ class Smarty_Internal_Config_File_Compiler
public function compileTemplate(Smarty_Internal_Template $template)
{
$this->template = $template;
$this->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->name, $this->template->source->getTimeStamp(), $this->template->source->type);
$this->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->filepath,
$this->template->source->getTimeStamp(),
$this->template->source->type);
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_compile($this->template);
}
// init the lexer/parser to compile the config file
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n", $this);
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) .
"\n", $this);
$parser = new $this->parser_class($lex, $this);
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
@@ -135,10 +139,12 @@ class Smarty_Internal_Config_File_Compiler
Smarty_Internal_Debug::end_compile($this->template);
}
// template header code
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " .
strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
$code = '<?php Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>';
$code = '<?php Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' .
var_export($this->config_data, true) . '); ?>';
return $template_header . Smarty_Internal_Extension_CodeFrame::create($this->template, $code);
}