From c404294a1f20ce5adb3caa90d778de89a282b941 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Thu, 26 Oct 2017 05:09:07 +0200 Subject: [PATCH] - bugfix Smarty version was not filled in header comment of compiled and cached files --- change_log.txt | 3 ++ .../smarty_internal_runtime_writefile.php | 30 ++++++++----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/change_log.txt b/change_log.txt index 982085f6..627c866b 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== 3.1.32 - dev === +26.10.2017 3.1.32-dev-28 + - bugfix Smarty version was not filled in header comment of compiled and cached files + 21.10.2017 - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23 https://github.com/smarty-php/smarty/issues/394 diff --git a/libs/sysplugins/smarty_internal_runtime_writefile.php b/libs/sysplugins/smarty_internal_runtime_writefile.php index ffa0b51e..dc9019f4 100644 --- a/libs/sysplugins/smarty_internal_runtime_writefile.php +++ b/libs/sysplugins/smarty_internal_runtime_writefile.php @@ -6,7 +6,6 @@ * @subpackage PluginsInternal * @author Monte Ohrt */ - /** * Smarty Internal Write File Class * @@ -35,34 +34,30 @@ class Smarty_Internal_Runtime_WriteFile if ($_file_perms !== null) { $old_umask = umask(0); } - $_dirpath = dirname($_filepath); - - // if subdirs, create dir structure + // if subdirs, create dir structure if ($_dirpath !== '.') { - $i=0; + $i = 0; // loop if concurrency problem occurs // see https://bugs.php.net/bug.php?id=35326 while (!is_dir($_dirpath)) { - if (@mkdir($_dirpath, $_dir_perms, true)) { - break; - } - clearstatcache(); - if (++$i === 3) { - error_reporting($_error_reporting); - throw new SmartyException("unable to create directory {$_dirpath}"); - } - sleep(1); + if (@mkdir($_dirpath, $_dir_perms, true)) { + break; + } + clearstatcache(); + if (++$i === 3) { + error_reporting($_error_reporting); + throw new SmartyException("unable to create directory {$_dirpath}"); + } + sleep(1); } } - // write to tmp file, then move to overt file lock race condition - $_tmp_file = $_dirpath . $smarty->ds . str_replace(array('.', ','), '_', uniqid('wrt', true)); + $_tmp_file = $_dirpath . DIRECTORY_SEPARATOR . 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}"); } - /* * Windows' rename() fails if the destination exists, * Linux' rename() properly handles the overwrite. @@ -99,7 +94,6 @@ class Smarty_Internal_Runtime_WriteFile umask($old_umask); } error_reporting($_error_reporting); - return true; } }