mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
bugfix variable filter might not have been loaded in cache file for use in nocache sections.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
20.11.2017
|
20.11.2017
|
||||||
- bugfix rework of newline spacing between tag code and template text.
|
- bugfix rework of newline spacing between tag code and template text.
|
||||||
now again identical with Smarty2 (forum topic 26878)
|
now again identical with Smarty2 (forum topic 26878)
|
||||||
|
- bugfix variable filter might not have been loaded in cache file for use in nocache sections.
|
||||||
|
|
||||||
05.11.2017
|
05.11.2017
|
||||||
- lexer/parser optimization
|
- lexer/parser optimization
|
||||||
|
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.32-dev-36';
|
const SMARTY_VERSION = '3.1.32-dev-37';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
|
@@ -100,18 +100,18 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) {
|
||||||
foreach ((array) $compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name)
|
foreach ((array) $compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name)
|
||||||
{
|
{
|
||||||
$result = $this->compile_output_filter($compiler, $name, $output);
|
$result = $this->compile_variable_filter($compiler, $name, $output);
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
$output = $result;
|
$output = $result;
|
||||||
} else {
|
} else {
|
||||||
// not found, throw exception
|
// not found, throw exception
|
||||||
throw new SmartyException("Unable to load filter '{$name}'");
|
throw new SmartyException("Unable to load variable filter '{$name}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($compiler->variable_filters as $filter) {
|
foreach ($compiler->variable_filters as $filter) {
|
||||||
if (count($filter) === 1 &&
|
if (count($filter) === 1 &&
|
||||||
($result = $this->compile_output_filter($compiler, $filter[ 0 ], $output)) !== false
|
($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
|
||||||
) {
|
) {
|
||||||
$output = $result;
|
$output = $result;
|
||||||
} else {
|
} else {
|
||||||
@@ -134,28 +134,14 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
private function compile_output_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
||||||
{
|
{
|
||||||
$plugin_name = "smarty_variablefilter_{$name}";
|
$function= $compiler->getPlugin($name, 'variablefilter');
|
||||||
$path = $compiler->smarty->loadPlugin($plugin_name);
|
if ($function) {
|
||||||
if ($path) {
|
return "{$function}({$output},\$_smarty_tpl)";
|
||||||
/**
|
} else {
|
||||||
if ($compiler->template->caching) {
|
|
||||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] =
|
|
||||||
$path;
|
|
||||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] =
|
|
||||||
$plugin_name;
|
|
||||||
} else {
|
|
||||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'file' ] =
|
|
||||||
$path;
|
|
||||||
$compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $name ][ Smarty::FILTER_VARIABLE ][ 'function' ] =
|
|
||||||
$plugin_name;
|
|
||||||
}
|
|
||||||
* */
|
|
||||||
return "{$plugin_name}({$output},\$_smarty_tpl)";
|
|
||||||
} else {
|
|
||||||
// not found
|
// not found
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user