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
|
||||
- bugfix rework of newline spacing between tag code and template text.
|
||||
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
|
||||
- lexer/parser optimization
|
||||
|
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.32-dev-36';
|
||||
const SMARTY_VERSION = '3.1.32-dev-37';
|
||||
/**
|
||||
* 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 ])) {
|
||||
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) {
|
||||
$output = $result;
|
||||
} else {
|
||||
// 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) {
|
||||
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;
|
||||
} else {
|
||||
@@ -134,25 +134,11 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
* @return string
|
||||
* @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}";
|
||||
$path = $compiler->smarty->loadPlugin($plugin_name);
|
||||
if ($path) {
|
||||
/**
|
||||
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)";
|
||||
$function= $compiler->getPlugin($name, 'variablefilter');
|
||||
if ($function) {
|
||||
return "{$function}({$output},\$_smarty_tpl)";
|
||||
} else {
|
||||
// not found
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user