From c23ce16cafb826c8bb4fe7aaf2a5525b29052b23 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 20:12:05 +0100 Subject: update smarty library - seems to bring some performance improvement --- .../sysplugins/smarty_internal_compile_insert.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php') diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php index 4c6585543..57f273506 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php @@ -51,8 +51,11 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - // never compile as nocache code - $compiler->suppressNocacheProcessing = true; + $nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache); + if (!$nocacheParam) { + // do not compile as nocache code + $compiler->suppressNocacheProcessing = true; + } $compiler->tag_nocache = true; $_smarty_tpl = $compiler->template; $_name = null; @@ -65,7 +68,12 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase // output will be stored in a smarty variable instead of being displayed $_assign = $_attr['assign']; // create variable to make sure that the compiler knows about its nocache status - $compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true); + $var = trim($_attr['assign'], "'"); + if (isset($compiler->template->tpl_vars[$var])) { + $compiler->template->tpl_vars[$var]->nocache = true; + } else { + $compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true); + } } if (isset($_attr['script'])) { // script which must be included @@ -116,19 +124,19 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase // convert attributes into parameter array string $_paramsArray = array(); foreach ($_attr as $_key => $_value) { - $_paramsArray[] = "'$_key' => $_value"; + $_paramsArray[] = "'$_key' => $_value"; } $_params = 'array(' . implode(", ", $_paramsArray) . ')'; // call insert if (isset($_assign)) { - if ($_smarty_tpl->caching) { + if ($_smarty_tpl->caching && !$nocacheParam) { $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>"; } else { $_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>"; } } else { $compiler->has_output = true; - if ($_smarty_tpl->caching) { + if ($_smarty_tpl->caching && !$nocacheParam) { $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>"; } else { $_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>"; -- cgit v1.2.3 From 26c465ad0c1d5b6801507ed190430f44ac92c672 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 6 Dec 2015 21:09:58 +0100 Subject: update smarty to 3.1.28-dev which fixes a bug where changes in a template are only visible on the second pageload which is annoying for developing --- .../sysplugins/smarty_internal_compile_insert.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php') diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php index 57f273506..2ebde1661 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php @@ -24,6 +24,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $required_attributes = array('name'); + /** * Attribute definition: Overwrites base class. * @@ -31,6 +32,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('name'); + /** * Attribute definition: Overwrites base class. * @@ -42,12 +44,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase /** * Compiles code for the {insert} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object + * @param array $args array with attributes from parser + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object * * @return string compiled code + * @throws \SmartyCompilerException */ - public function compile($args, $compiler) + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) { // check and get attributes $_attr = $this->getAttributes($compiler, $args); @@ -63,7 +66,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase $_output = 'template; $_filepath = false; - eval('$_script = ' . $_attr['script'] . ';'); + eval('$_script = @' . $_attr['script'] . ';'); if (!isset($compiler->smarty->security_policy) && file_exists($_script)) { $_filepath = $_script; } else { @@ -100,13 +103,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase } } if ($_filepath == false) { - $compiler->trigger_template_error("{insert} missing script file '{$_script}'", $compiler->lex->taglineno); + $compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true); } // code for script file loading $_output .= "require_once '{$_filepath}' ;"; require_once $_filepath; if (!is_callable($_function)) { - $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", $compiler->lex->taglineno); + $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", null, true); } } else { $_filepath = 'null'; @@ -115,7 +118,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase if (!is_callable($_function)) { // try plugin if (!$_function = $compiler->getPlugin($_name, 'insert')) { - $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", $compiler->lex->taglineno); + $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null, true); } } } @@ -124,7 +127,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase // convert attributes into parameter array string $_paramsArray = array(); foreach ($_attr as $_key => $_value) { - $_paramsArray[] = "'$_key' => $_value"; + $_paramsArray[] = "'$_key' => $_value"; } $_params = 'array(' . implode(", ", $_paramsArray) . ')'; // call insert -- cgit v1.2.3