diff --git a/change_log.txt b/change_log.txt index 130a5b14..c6379b44 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 11/12/2010 - bugfix nested block tags in template inheritance child templates did not work correctly - bugfix {$smarty.current_dir} in child template did not point to dir of child template +- bugfix changed code when writing temporary compiled files to allow stream_wrapper 06/12/2010 - bugfix getTemplateVars() should return 'null' instead dropping E_NOTICE on an unassigned variable diff --git a/libs/sysplugins/smarty_internal_write_file.php b/libs/sysplugins/smarty_internal_write_file.php index 6ec5e2df..b7085239 100644 --- a/libs/sysplugins/smarty_internal_write_file.php +++ b/libs/sysplugins/smarty_internal_write_file.php @@ -30,11 +30,17 @@ class Smarty_Internal_Write_File { // write to tmp file, then move to overt file lock race condition $_tmp_file = tempnam($_dirpath, 'wrt'); - if (!file_put_contents($_tmp_file, $_contents)) { - umask($old_umask); + if (!($fd = @fopen($_tmp_file, 'wb'))) { + $_tmp_file = $_dirname . DS . uniqid('wrt'); + if (!($fd = @fopen($_tmp_file, 'wb'))) { throw new SmartyException("unable to write file {$_tmp_file}"); return false; - } + } + } + + fwrite($fd, $_contents); + fclose($fd); + // remove original file if (file_exists($_filepath)) @unlink($_filepath);