diff --git a/change_log.txt b/change_log.txt index ce604dd3..77356cfc 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,8 @@ ===== 3.1.32 - dev === +30.7.2017 + - rewrite mkdir() bugfix to retry automatically see https://github.com/smarty-php/smarty/pull/377 + https://github.com/smarty-php/smarty/pull/379 + 21.7.2017 - security possible PHP code injection on custom resources at display() or fetch() calls if the resource does not sanitize the template name diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 234a4191..5f5580a3 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-14'; + const SMARTY_VERSION = '3.1.32-dev-15'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_runtime_writefile.php b/libs/sysplugins/smarty_internal_runtime_writefile.php index 93f73125..84de5674 100644 --- a/libs/sysplugins/smarty_internal_runtime_writefile.php +++ b/libs/sysplugins/smarty_internal_runtime_writefile.php @@ -39,9 +39,20 @@ class Smarty_Internal_Runtime_WriteFile $_dirpath = dirname($_filepath); // if subdirs, create dir structure - if ($_dirpath !== '.' && !@mkdir($_dirpath, $_dir_perms, true) && !is_dir($_dirpath)) { - error_reporting($_error_reporting); - throw new SmartyException("unable to create directory {$_dirpath}"); + if ($_dirpath !== '.') { + $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; + } + 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