From 4e1d6707fe6511f22424b109e2b7444afe5416de Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 18 Oct 2015 22:12:16 +0200 Subject: [PATCH] - update code generated by template function call handler --- change_log.txt | 1 + libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_function_call_handler.php | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index 1c0c4348..5656ef4e 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,7 @@ - speed and size optimizations - bugfix under HHVM temporary cache file must only be created when caches template was updated - fix compiled code for new {block} assign attribute + - update code generated by template function call handler 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 d31a3588..e2e99eb3 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/65'; + const SMARTY_VERSION = '3.1.28-dev/66'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_function_call_handler.php b/libs/sysplugins/smarty_internal_function_call_handler.php index a6a7fb48..dc3c264a 100644 --- a/libs/sysplugins/smarty_internal_function_call_handler.php +++ b/libs/sysplugins/smarty_internal_function_call_handler.php @@ -53,10 +53,12 @@ class Smarty_Internal_Function_Call_Handler $content = $cache->read($tplPtr); if ($content) { // check if we must update file dependency - if (!preg_match("/'{$funcParam['uid']}'([\S\s]*?)'nocache_hash'/", $content, $match2)) { - $content = preg_replace("/('file_dependency'([\S\s]*?)\()/", "\\1{$match1[0]}", $content); + if (!preg_match("/'{$funcParam['uid']}'(.*?)'nocache_hash'/", $content, $match2)) { + $content = preg_replace("/('file_dependency'(.*?)\()/", "\\1{$match1[0]}", $content); } - $cache->write($tplPtr, $content . "\n"); + $cache->write($tplPtr, preg_replace('/\s*\?>\s*$/', "\n", $content) . "\n" . + preg_replace(array('/^\s*<\?php\s+/', '/\s*\?>\s*$/'), "\n", + $match[0])); } } return true;