Cherry-picked from da76d927ed

Co-Authored-By: Thomas BACCELLI <tbaccelli@gmail.com>
This commit is contained in:
Thomas A. Hirsch
2022-01-18 13:57:58 +01:00
parent cdf0f2b164
commit 8d3a7af308
9 changed files with 14 additions and 13 deletions

View File

@@ -157,7 +157,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n";
$output .= "}\n}\n";
$output .= "/*/ {$_funcName}_nocache */\n\n";
$output .= "?>\n";

View File

@@ -158,7 +158,7 @@ class Smarty_Internal_Config_File_Compiler
}
// template header code
$template_header =
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . date("Y-m-d H:i:s") .
"\n";
$template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .

View File

@@ -45,7 +45,7 @@ class Smarty_Internal_Runtime_CodeFrame
$properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
}
$output = "<?php\n";
$output .= "/* Smarty version {$properties[ 'version' ]}, created on " . strftime("%Y-%m-%d %H:%M:%S") .
$output .= "/* Smarty version {$properties[ 'version' ]}, created on " . date("Y-m-d H:i:s") .
"\n from '" . str_replace('*/', '* /', $_template->source->filepath) . "' */\n\n";
$output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n";
$dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .

View File

@@ -1135,7 +1135,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
flush();
}
$e = new SmartyCompilerException($error_text);
$e->line = $line;
$e->setLine($line);
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
$e->desc = $args;
$e->template = $this->template->source->filepath;

View File

@@ -16,12 +16,12 @@ class SmartyCompilerException extends SmartyException
}
/**
* The line number of the template error
*
* @type int|null
* @param int $line
*/
public $line = null;
public function setLine($line)
{
$this->line = $line;
}
/**
* The template source snippet relating to the error
*

View File

@@ -30,7 +30,8 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
public function compiledPrefilter($text, Smarty_Internal_Template $tpl)
{
return str_replace('#', $tpl->getTemplateVars('test'), $text);
$replace = $tpl->getTemplateVars('test');
return str_replace('#', $replace ?? '', $text);
}
/**

View File

@@ -234,7 +234,7 @@ class ResourceStream
$v = &$GLOBALS[$this->varname];
$l = strlen($data);
$p = &$this->position;
$v = substr($v, 0, $p) . $data . substr($v, $p += $l);
$v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l);
return $l;
}

View File

@@ -416,7 +416,7 @@ class ResourceStreamSecurity
$v = &$GLOBALS[$this->varname];
$l = strlen($data);
$p = &$this->position;
$v = substr($v, 0, $p) . $data . substr($v, $p += $l);
$v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l);
return $l;
}

View File

@@ -96,7 +96,7 @@ class VariableStream
$v = &$GLOBALS[$this->varname];
$l = strlen($data);
$p = &$this->position;
$v = substr($v, 0, $p) . $data . substr($v, $p += $l);
$v = substr($v ?? '', 0, $p) . $data . substr($v ?? '', $p += $l);
return $l;
}