diff --git a/NEWS b/NEWS index 6894779a..36f0566d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - fall back to old uniqid()-behaviour when tempnam() fails in + core.write_file.php (messju) - fix capitalize modifier, don't rely on buggy ucwords (Monte) - make html_select_date work with negative timestamps, also force year range to include given date unless explicitly diff --git a/libs/core/core.write_file.php b/libs/core/core.write_file.php index f889f2a1..ea08adb8 100644 --- a/libs/core/core.write_file.php +++ b/libs/core/core.write_file.php @@ -25,11 +25,14 @@ function smarty_core_write_file($params, &$smarty) // write to tmp file, then rename it to avoid // file locking race condition - $_tmp_file = tempnam($_dirname, 'write_'); + $_tmp_file = tempnam($_dirname, 'wrt'); - if (!($fd = @fopen($_tmp_file, 'w'))) { - $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); - return false; + if (!($fd = @fopen($_tmp_file, 'wb'))) { + $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt'); + if (!($fd = @fopen($_tmp_file, 'wb'))) { + $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); + return false; + } } fwrite($fd, $params['contents']);