From 6baca38bf147dac4a6590740b735d891c844acbb Mon Sep 17 00:00:00 2001 From: rodneyrehm Date: Fri, 21 Oct 2011 12:10:41 +0000 Subject: [PATCH] - improvement sha1() for array keys longer than 150 characters --- change_log.txt | 3 ++- libs/Smarty.class.php | 3 +++ libs/sysplugins/smarty_cacheresource_keyvaluestore.php | 3 +++ libs/sysplugins/smarty_internal_cacheresource_file.php | 3 +++ libs/sysplugins/smarty_internal_template.php | 6 ++++++ libs/sysplugins/smarty_internal_utility.php | 3 +++ 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 472a70d6..4bc507fd 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ ===== trunk ===== 21.10.2011 -- bugfix apostrope in plugins_dir path name failed (forum topic 20199) +- bugfix apostrophe in plugins_dir path name failed (forum topic 20199) +- improvement sha1() for array keys longer than 150 characters 20.10.2011 - @silenced unlink() in Smarty_Internal_Write_File since debuggers go haywire without it. diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 3cebaa12..34ca6971 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1174,6 +1174,9 @@ class Smarty extends Smarty_Internal_TemplateBase { // already in template cache? $unique_template_name = Smarty_Resource::getUniqueTemplateName($this, $template); $_templateId = $unique_template_name . $cache_id . $compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } if ($do_clone) { if (isset($this->template_objects[$_templateId])) { // return cached template object diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index fff90ea0..7dd75f85 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -179,6 +179,9 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource { // remove from template cache $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } unset($smarty->template_objects[$_templateId]); } return $uid; diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index b3ad959f..17d90a17 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -155,6 +155,9 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource { // remove from template cache $tpl->source; // have the template registered before unset() $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } unset($smarty->template_objects[$_templateId]); if ($tpl->source->exists) { diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 559ef307..d5d8c585 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -247,6 +247,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { // already in template cache? $unique_template_name = Smarty_Resource::getUniqueTemplateName($this->smarty, $template); $_templateId = $unique_template_name . $cache_id . $compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } if (isset($this->smarty->template_objects[$_templateId])) { // clone cached template object because of possible recursive call $tpl = clone $this->smarty->template_objects[$_templateId]; @@ -623,6 +626,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { // do not cache eval resources if ($this->source->type != 'eval') { $_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } $this->smarty->template_objects[$_templateId] = $this; } return $this->source; diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php index 95eddad3..8d7b2db5 100644 --- a/libs/sysplugins/smarty_internal_utility.php +++ b/libs/sysplugins/smarty_internal_utility.php @@ -193,6 +193,9 @@ class Smarty_Internal_Utility { // remove from template cache $tpl->source; // have the template registered before unset() $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id; + if (isset($_templateId[150])) { + $_templateId = sha1($_templateId); + } unset($smarty->template_objects[$_templateId]); if ($tpl->source->exists) {