diff --git a/change_log.txt b/change_log.txt index 43595e74..12c2bb29 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.28-dev===== (xx.xx.2015) + 26.07.2015 + - improvement impement workaround for HHVM PHP incompatibillity https://github.com/facebook/hhvm/issues/4797 + 25.07.2015 - bugfix parser did hang on text starting cached; diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index 2fdc7e42..99df6f31 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -81,10 +81,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * * @param Smarty_Internal_Template $_template template object * @param Smarty_Template_Cached $cached cached object + * @param bool $update flag if called because cache update * * @return boolean true or false if the cached content does not exist */ - public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null) + public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false) { if (!$cached) { $cached = $_template->cached; diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index d0ab4ec5..528ea01c 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -86,17 +86,21 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource * * @param Smarty_Internal_Template $_template template object * @param Smarty_Template_Cached $cached cached object + * @param bool $update flag if called because cache update * * @return boolean true or false if the cached content does not exist */ - public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null) + public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false) { /** @var Smarty_Internal_Template $_smarty_tpl * used in included file */ $_smarty_tpl = $_template; - - return @include $_template->cached->filepath; + if (strpos(phpversion(), 'hhvm') !== false) { + 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 new file mode 100644 index 00000000..7d55a454 --- /dev/null +++ b/libs/sysplugins/smarty_internal_extension_hhvm.php @@ -0,0 +1,31 @@ +smarty->getCompileDir() . 'hhvm' . + str_replace(array('.', ','), '_', uniqid(rand(), true)) . '.php'; + file_put_contents($tmp_file, file_get_contents($file)); + $result = @include $tmp_file; + @unlink($tmp_file); + return $result; + } +} \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 73a183c3..928bef98 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -291,7 +291,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $this->properties['tpl_function'] = $this->parent->properties['tpl_function']; } if (!$this->cached->processed) { - $this->cached->process($this); + $this->cached->process($this, true); } $this->smarty->compile_check = $compile_check; $content = $this->getRenderedTemplateCode(); diff --git a/libs/sysplugins/smarty_template_cached.php b/libs/sysplugins/smarty_template_cached.php index 2a467111..9d0deace 100644 --- a/libs/sysplugins/smarty_template_cached.php +++ b/libs/sysplugins/smarty_template_cached.php @@ -210,10 +210,11 @@ class Smarty_Template_Cached * Process cached template * * @param Smarty_Internal_Template $_template template object + * @param bool $update flag if called because cache update */ - public function process(Smarty_Internal_Template $_template) + public function process(Smarty_Internal_Template $_template, $update = false) { - if ($this->handler->process($_template, $this) === false) { + if ($this->handler->process($_template, $this, $update) === false) { $this->valid = false; } if ($this->valid) { diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index e0e5dbcb..22f47c1b 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -176,7 +176,11 @@ class Smarty_Template_Compiled if (function_exists('opcache_invalidate')) { opcache_invalidate($_template->compiled->filepath); } - include($_template->compiled->filepath); + if (strpos(phpversion(), 'hhvm') !== false) { + Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->compiled->filepath); + } else { + include($_template->compiled->filepath); + } } $_template->smarty->compile_check = $compileCheck; } else { @@ -188,7 +192,11 @@ class Smarty_Template_Compiled if (function_exists('opcache_invalidate')) { opcache_invalidate($_template->compiled->filepath); } - include($_template->compiled->filepath); + if (strpos(phpversion(), 'hhvm') !== false) { + Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->compiled->filepath); + } else { + include($_template->compiled->filepath); + } $_template->smarty->compile_check = $compileCheck; } }