From 4776491a7f6480cceac1c8f6892383bbfac76457 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 18 Oct 2015 04:58:53 +0200 Subject: [PATCH] - bugfix under HHVM temporary cache file must only be created when caches template was updated --- change_log.txt | 1 + libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_cacheresource_file.php | 2 +- libs/sysplugins/smarty_internal_extension_hhvm.php | 3 +-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index c260e26c..8b994449 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - optimize filepath normalization - rework of template inheritance - speed and size optimizations + - bugfix under HHVM temporary cache file must only be created when caches template was updated 18.09.2015 - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 037cbabf..17e537d5 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.28-dev/63'; + const SMARTY_VERSION = '3.1.28-dev/64'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 50233f7b..a438b4bb 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -96,7 +96,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource * used in included file */ $_smarty_tpl = $_template; - if (strpos(phpversion(), 'hhvm') !== false) { + if ($update && defined('HHVM_VERSION')) { return Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->cached->filepath); } else { return @include $_template->cached->filepath; diff --git a/libs/sysplugins/smarty_internal_extension_hhvm.php b/libs/sysplugins/smarty_internal_extension_hhvm.php index 7d55a454..18b6a3eb 100644 --- a/libs/sysplugins/smarty_internal_extension_hhvm.php +++ b/libs/sysplugins/smarty_internal_extension_hhvm.php @@ -21,8 +21,7 @@ class Smarty_Internal_Extension_Hhvm static function includeHhvm(Smarty_Internal_Template $_template, $file) { $_smarty_tpl = $_template; - $tmp_file = $_template->smarty->getCompileDir() . 'hhvm' . - str_replace(array('.', ','), '_', uniqid(rand(), true)) . '.php'; + $tmp_file = $file . preg_replace('![^\w]+!', '_', uniqid(rand(), true)) . '.php'; file_put_contents($tmp_file, file_get_contents($file)); $result = @include $tmp_file; @unlink($tmp_file);