From fa09638f9566f51aa2d7068b65a054e89af63e4b Mon Sep 17 00:00:00 2001 From: "monte.ohrt" Date: Tue, 17 Dec 2013 16:06:12 +0000 Subject: [PATCH 01/14] update changelog --- change_log.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/change_log.txt b/change_log.txt index 075077c5..90a598f8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,5 @@ ===== trunk ===== + ===== 3.1.16 ===== 15.12.2013 - bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161) Read 3.1.16_RELEASE_NOTES for more details From 797bd37c5f1abdab3147d2eb0d21fb351ac0d3e0 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Wed, 8 Jan 2014 21:05:58 +0000 Subject: [PATCH 02/14] - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) --- change_log.txt | 3 ++ .../smarty_cacheresource_custom.php | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 90a598f8..1daa35e9 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 08.01.2014 + - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) + ===== 3.1.16 ===== 15.12.2013 - bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161) diff --git a/libs/sysplugins/smarty_cacheresource_custom.php b/libs/sysplugins/smarty_cacheresource_custom.php index a81b545a..f6c9d61d 100644 --- a/libs/sysplugins/smarty_cacheresource_custom.php +++ b/libs/sysplugins/smarty_cacheresource_custom.php @@ -186,8 +186,34 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) { $this->cache = array(); + $cache_name = null; - return $this->delete($resource_name, $cache_id, $compile_id, $exp_time); + if (isset($resource_name)) { + $_save_stat = $smarty->caching; + $smarty->caching = true; + $tpl = new $smarty->template_class($resource_name, $smarty); + $smarty->caching = $_save_stat; + + if ($tpl->source->exists) { + $cache_name = $tpl->source->name; + } else { + return 0; + } + // remove from template cache + if ($smarty->allow_ambiguous_resources) { + $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; + } else { + $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id; + } + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } + unset($smarty->template_objects[$_templateId]); + // template object no longer needed + unset($tpl); + } + + return $this->delete($cache_name, $cache_id, $compile_id, $exp_time); } /** From 54d5d949de72aad394b30a11c443cee9fae104d0 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Wed, 8 Jan 2014 21:16:06 +0000 Subject: [PATCH 03/14] - bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683) --- change_log.txt | 1 + libs/SmartyBC.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 1daa35e9..cf6130bf 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ ===== trunk ===== 08.01.2014 - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) + - bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683) ===== 3.1.16 ===== 15.12.2013 diff --git a/libs/SmartyBC.class.php b/libs/SmartyBC.class.php index 32f22289..3c1a0aa9 100644 --- a/libs/SmartyBC.class.php +++ b/libs/SmartyBC.class.php @@ -32,7 +32,7 @@ /** * @ignore */ -require(dirname(__FILE__) . '/Smarty.class.php'); +require_once(dirname(__FILE__) . '/Smarty.class.php'); /** * Smarty Backward Compatability Wrapper Class From 18ff092501125841a3eb2aa0c4a19bf24dab9acf Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sat, 11 Jan 2014 12:15:37 +0000 Subject: [PATCH 04/14] --- change_log.txt | 5 ++++- libs/sysplugins/smarty_internal_templatelexer.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index cf6130bf..3abb9505 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,9 @@ ===== trunk ===== + 11.01.2014 + - bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170) + 08.01.2014 - - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) + - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169) - bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683) ===== 3.1.16 ===== diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index aeb1bd4d..1661166d 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -167,7 +167,7 @@ class Smarty_Internal_Templatelexer if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) { return false; // end of input } - $yy_global_pattern = "/\G(\\{\\})|\G(".$this->ldel."\\s*\\*([\S\s]*?)\\*\\s*".$this->rdel.")|\G(".$this->ldel."\\s*strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s*\/)|\G(".$this->ldel."\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*".$this->rdel.")|\G(<%)|\G(%>)|\G([\S\s])/iS"; + $yy_global_pattern = "/\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."\\s*strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/strip\\s*".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s*\/)|\G(".$this->ldel."\\s*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(\\s*".$this->rdel.")|\G(<%)|\G(%>)|\G([\S\s])/iS"; do { if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { From 1dfbe19ebf7bf72bdbd661f7fe926e7ecb226dc8 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sat, 11 Jan 2014 12:21:12 +0000 Subject: [PATCH 05/14] - internals content cache should be clear when updating cache file --- change_log.txt | 1 + libs/sysplugins/smarty_cacheresource.php | 1 + 2 files changed, 2 insertions(+) diff --git a/change_log.txt b/change_log.txt index 3abb9505..af6db318 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ ===== trunk ===== 11.01.2014 - bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170) + - internals content cache should be clear when updating cache file 08.01.2014 - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169) diff --git a/libs/sysplugins/smarty_cacheresource.php b/libs/sysplugins/smarty_cacheresource.php index efdc1abe..22262bae 100644 --- a/libs/sysplugins/smarty_cacheresource.php +++ b/libs/sysplugins/smarty_cacheresource.php @@ -372,6 +372,7 @@ class Smarty_Template_Cached { if (!$_template->source->recompiled) { if ($this->handler->writeCachedContent($_template, $content)) { + $this->content = null; $this->timestamp = time(); $this->exists = true; $this->valid = true; From 290dd3f73f08184b2c0845ef509648b382276e2a Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sat, 18 Jan 2014 14:43:02 +0000 Subject: [PATCH 06/14] - bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group) --- change_log.txt | 5 ++++- libs/sysplugins/smarty_internal_compile_include.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index af6db318..d6affe73 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,8 @@ ===== trunk ===== - 11.01.2014 + 18.01.2014 + - bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group) + + 11.01.2014 - bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170) - internals content cache should be clear when updating cache file diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 1ea8b577..27ad617e 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -166,7 +166,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $nocache = false; $_smarty_tpl = $compiler->template; eval("\$tpl_name = $include_file;"); - if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid]) || $compiler->inheritance) { + 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); // save unique function name $compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace('.', '_', uniqid('', true)); From 0e03ba5b6116e67fe4f1617cb3a3fd2ecdc02029 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sun, 26 Jan 2014 20:11:19 +0000 Subject: [PATCH 07/14] - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_nocache.php | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/change_log.txt b/change_log.txt index d6affe73..115f4786 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 26.01.2014 + - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) + 18.01.2014 - bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group) diff --git a/libs/sysplugins/smarty_internal_compile_nocache.php b/libs/sysplugins/smarty_internal_compile_nocache.php index a0e15385..f4e623c6 100644 --- a/libs/sysplugins/smarty_internal_compile_nocache.php +++ b/libs/sysplugins/smarty_internal_compile_nocache.php @@ -32,11 +32,8 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase if ($_attr['nocache'] === true) { $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno); } - if ($compiler->template->caching) { // enter nocache mode - $this->openTag($compiler, 'nocache', $compiler->nocache); $compiler->nocache = true; - } // this tag does not return compiled code $compiler->has_code = false; @@ -65,10 +62,8 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase public function compile($args, $compiler) { $_attr = $this->getAttributes($compiler, $args); - if ($compiler->template->caching) { - // restore old nocache mode - $compiler->nocache = $this->closeTag($compiler, 'nocache'); - } + // leave nocache mode + $compiler->nocache = false; // this tag does not return compiled code $compiler->has_code = false; From 79dfde49779ec47c1660cc4f41b766064bfdde5f Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Mon, 27 Jan 2014 16:08:55 +0000 Subject: [PATCH 08/14] - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_templatebase.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 115f4786..3c3a7553 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 27.01.2014 + - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) + 26.01.2014 - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index 8ce6d5ec..7447940b 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -343,7 +343,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data } // debug output if ($this->smarty->debugging) { - Smarty_Internal_Debug::display_debug($this); + Smarty_Internal_Debug::display_debug($_template); } if ($merge_tpl_vars) { // restore local variables From ba2996fef584162bb82b6699c9b2acdb8405840c Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Mon, 27 Jan 2014 16:35:56 +0000 Subject: [PATCH 09/14] - bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171) --- change_log.txt | 1 + libs/sysplugins/smarty_internal_cacheresource_file.php | 2 +- libs/sysplugins/smarty_internal_utility.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/change_log.txt b/change_log.txt index 3c3a7553..fe652892 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ ===== trunk ===== 27.01.2014 - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) + - bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171) 26.01.2014 - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 049cc91b..ad728340 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -139,7 +139,7 @@ $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; - $_dir = $smarty->getCacheDir(); + $_dir = realpath($smarty->getCacheDir()); $_dir_length = strlen($_dir); if (isset($_cache_id)) { $_cache_id_parts = explode('|', $_cache_id); diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php index 33091eaf..55509ded 100644 --- a/libs/sysplugins/smarty_internal_utility.php +++ b/libs/sysplugins/smarty_internal_utility.php @@ -182,7 +182,7 @@ class Smarty_Internal_Utility */ public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty) { - $_compile_dir = $smarty->getCompileDir(); + $_compile_dir = realpath($smarty->getCompileDir()); $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_dir_sep = $smarty->use_sub_dirs ? DS : '^'; if (isset($resource_name)) { From f242ce30fb3ad728620aca22379c0aa1da7fdf3a Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Wed, 5 Feb 2014 19:39:21 +0000 Subject: [PATCH 10/14] - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) --- change_log.txt | 3 +++ libs/plugins/shared.literal_compiler_param.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index fe652892..684920c1 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 05.02.2014 + - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) + 27.01.2014 - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) - bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171) diff --git a/libs/plugins/shared.literal_compiler_param.php b/libs/plugins/shared.literal_compiler_param.php index 1420a0e2..f709f188 100644 --- a/libs/plugins/shared.literal_compiler_param.php +++ b/libs/plugins/shared.literal_compiler_param.php @@ -23,7 +23,7 @@ function smarty_literal_compiler_param($params, $index, $default=null) return $default; } // test if param is a literal - if (!preg_match('/^([\'"]?)[a-zA-Z0-9]+(\\1)$/', $params[$index])) { + if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[$index])) { throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time'); } From bfa0ce8ba4565e7bbc9a909f27f9640415c68139 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sun, 16 Feb 2014 18:34:08 +0000 Subject: [PATCH 11/14] - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) --- change_log.txt | 3 +++ libs/Smarty.class.php | 42 +++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/change_log.txt b/change_log.txt index 684920c1..82d0d1e1 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 16.02.2014 + - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) + 05.02.2014 - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 893ffb2e..a3edac7d 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -835,7 +835,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->template_dir = array(); foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS; } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); @@ -858,20 +858,24 @@ class Smarty extends Smarty_Internal_TemplateBase if (is_array($template_dir)) { foreach ($template_dir as $k => $v) { + $v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->template_dir[] = rtrim($v, '/\\') . DS; + $this->template_dir[] = $v; } else { // string indexes are overridden - $this->template_dir[$k] = rtrim($v, '/\\') . DS; + $this->template_dir[$k] = $v; } } - } elseif ($key !== null) { - // override directory at specified index - $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS; - } else { - // append new directory - $this->template_dir[] = rtrim($template_dir, '/\\') . DS; + } else { + $v = str_replace(array('//','\\\\'), DS, rtrim($template_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->template_dir[$key] = $v; + } else { + // append new directory + $this->template_dir[] = $v; + } } $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); @@ -903,7 +907,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->config_dir = array(); foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS; } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); @@ -925,20 +929,24 @@ class Smarty extends Smarty_Internal_TemplateBase if (is_array($config_dir)) { foreach ($config_dir as $k => $v) { + $v = str_replace(array('//','\\\\'), DS, rtrim($v, '/\\')) . DS; if (is_int($k)) { // indexes are not merged but appended - $this->config_dir[] = rtrim($v, '/\\') . DS; + $this->config_dir[] = $v; } else { // string indexes are overridden - $this->config_dir[$k] = rtrim($v, '/\\') . DS; + $this->config_dir[$k] = $v; } } - } elseif ($key !== null) { - // override directory at specified index - $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS; } else { - // append new directory - $this->config_dir[] = rtrim($config_dir, '/\\') . DS; + $v = str_replace(array('//','\\\\'), DS, rtrim($config_dir, '/\\')) . DS; + if ($key !== null) { + // override directory at specified index + $this->config_dir[$key] = rtrim($v, '/\\') . DS; + } else { + // append new directory + $this->config_dir[] = rtrim($v, '/\\') . DS; + } } $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); From f06013927c187ce1cb7da136320e369863bfb2ef Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Mon, 17 Feb 2014 18:21:31 +0000 Subject: [PATCH 12/14] - bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_include.php | 2 +- libs/sysplugins/smarty_internal_template.php | 4 ++-- libs/sysplugins/smarty_internal_templatecompilerbase.php | 2 +- libs/sysplugins/smarty_internal_write_file.php | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/change_log.txt b/change_log.txt index 82d0d1e1..800de6f2 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== 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 - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 27ad617e..eb356cfa 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -169,7 +169,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase 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); // 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 $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) { diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index c2bf4501..47dac93d 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -217,7 +217,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase return false; } $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); $_smarty_tpl = $this; eval("?>" . $content); @@ -399,7 +399,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } $this->properties['version'] = Smarty::SMARTY_VERSION; 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) { $output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . ',' . ($cache ? 'true' : 'false') . "); /*/%%SmartyHeaderCode%%*/?>\n"; diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index d7268fbf..fcfb25ef 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -203,7 +203,7 @@ abstract class Smarty_Internal_TemplateCompilerBase */ public function __construct() { - $this->nocache_hash = str_replace('.', '-', uniqid(rand(), true)); + $this->nocache_hash = str_replace(array('.',','), '-', uniqid(rand(), true)); } /** diff --git a/libs/sysplugins/smarty_internal_write_file.php b/libs/sysplugins/smarty_internal_write_file.php index a62fa947..770b56f5 100644 --- a/libs/sysplugins/smarty_internal_write_file.php +++ b/libs/sysplugins/smarty_internal_write_file.php @@ -38,7 +38,7 @@ class Smarty_Internal_Write_File } // 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)) { error_reporting($_error_reporting); throw new SmartyException("unable to write file {$_tmp_file}"); From af13907219106fcef2b4cb78ae5943756c3c8ff9 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews@googlemail.com" Date: Sat, 8 Mar 2014 23:03:08 +0000 Subject: [PATCH 13/14] 08.03.2014 - bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177) --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_block.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/change_log.txt b/change_log.txt index 800de6f2..f76ec278 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== + 08.03.2014 + - bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177) + 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) diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index ba26ed0a..377288df 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -376,6 +376,13 @@ class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_Compil // check and get attributes $_attr = $this->getAttributes($compiler, $args); + // update template with original template resource of {block} + $compiler->template->template_resource = realpath(trim($_attr['file'], "'")); + // source object + unset ($compiler->template->source); + $exists = $compiler->template->source->exists; + + // must merge includes if ($_attr['nocache'] == true) { $compiler->tag_nocache = true; From 40acefe91b75d6ec6c12811a1781af25b5ec33dd Mon Sep 17 00:00:00 2001 From: "monte.ohrt" Date: Wed, 12 Mar 2014 19:50:58 +0000 Subject: [PATCH 14/14] update changelog --- change_log.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/change_log.txt b/change_log.txt index f76ec278..64fd1f87 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,5 @@ ===== trunk ===== + ===== 3.1.17 ===== 08.03.2014 - bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)