- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)

This commit is contained in:
Uwe.Tews@googlemail.com
2014-02-17 18:21:31 +00:00
parent bfa0ce8ba4
commit f06013927c
5 changed files with 8 additions and 5 deletions

View File

@@ -1,4 +1,7 @@
===== trunk ===== ===== trunk =====
17.02.2014
- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)
16.02.2014 16.02.2014
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)

View File

@@ -169,7 +169,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid])) { if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid])) {
$tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id); $tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id);
// save unique function name // save unique function name
$compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); $compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
// use current nocache hash for inlined code // use current nocache hash for inlined code
$compiler->smarty->merged_templates_func[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; $compiler->smarty->merged_templates_func[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
if ($compiler->template->caching && $_caching == self::CACHING_NOCACHE_CODE) { if ($compiler->template->caching && $_caching == self::CACHING_NOCACHE_CODE) {

View File

@@ -217,7 +217,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
return false; return false;
} }
$this->properties['cache_lifetime'] = $this->cache_lifetime; $this->properties['cache_lifetime'] = $this->cache_lifetime;
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); $this->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
$content = $this->createTemplateCodeFrame($content, true); $content = $this->createTemplateCodeFrame($content, true);
$_smarty_tpl = $this; $_smarty_tpl = $this;
eval("?>" . $content); eval("?>" . $content);
@@ -399,7 +399,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
} }
$this->properties['version'] = Smarty::SMARTY_VERSION; $this->properties['version'] = Smarty::SMARTY_VERSION;
if (!isset($this->properties['unifunc'])) { if (!isset($this->properties['unifunc'])) {
$this->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); $this->properties['unifunc'] = 'content_' . str_replace(array('.',','), '_', uniqid('', true));
} }
if (!$this->source->recompiled) { if (!$this->source->recompiled) {
$output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . ',' . ($cache ? 'true' : 'false') . "); /*/%%SmartyHeaderCode%%*/?>\n"; $output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . ',' . ($cache ? 'true' : 'false') . "); /*/%%SmartyHeaderCode%%*/?>\n";

View File

@@ -203,7 +203,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/ */
public function __construct() public function __construct()
{ {
$this->nocache_hash = str_replace('.', '-', uniqid(rand(), true)); $this->nocache_hash = str_replace(array('.',','), '-', uniqid(rand(), true));
} }
/** /**

View File

@@ -38,7 +38,7 @@ class Smarty_Internal_Write_File
} }
// write to tmp file, then move to overt file lock race condition // write to tmp file, then move to overt file lock race condition
$_tmp_file = $_dirpath . DS . uniqid('wrt', true); $_tmp_file = $_dirpath . DS . str_replace(array('.',','), '_', uniqid('wrt', true));
if (!file_put_contents($_tmp_file, $_contents)) { if (!file_put_contents($_tmp_file, $_contents)) {
error_reporting($_error_reporting); error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_tmp_file}"); throw new SmartyException("unable to write file {$_tmp_file}");