cvs: smarty / NEWS /libs/core core.write_file.php
"Messju Mohr" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmessju1083847066@cvsserver> |
messju Thu May 6 08:37:46 2004 EDT
Modified files:
/smarty NEWS
/smarty/libs/core core.write_file.php
Log:
use tempnam() instead of unqid() to create better temporary files in
smarty_core_write_file().
(thanks to xces for finding this race-condition and his work on
fixing it)
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.449&r2=1.450&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.449 smarty/NEWS:1.450
--- smarty/NEWS:1.449 Fri Apr 30 10:50:17 2004
+++ smarty/NEWS Thu May 6 08:37:45 2004
@@ -1,3 +1,5 @@
+ - use tempnam() instead of unqid() to create better temporary files in
+ smarty_core_write_file() (xces, messju)
- add 'mail' to escape modifier for safe display of e-mail
addresses (Monte)
- add cycle function attribute "reset" to english docs (Monte)
http://cvs.php.net/diff.php/smarty/libs/core/core.write_file.php?r1=1.10&r2=1.11&ty=u
Index: smarty/libs/core/core.write_file.php
diff -u smarty/libs/core/core.write_file.php:1.10 smarty/libs/core/core.write_file.php:1.11
--- smarty/libs/core/core.write_file.php:1.10 Fri Apr 16 04:02:04 2004
+++ smarty/libs/core/core.write_file.php Thu May 6 08:37:46 2004
@@ -25,7 +25,7 @@
// write to tmp file, then rename it to avoid
// file locking race condition
- $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('');
+ $_tmp_file = tempnam($_dirname, 'write_');
if (!($fd = @fopen($_tmp_file, 'w'))) {
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
@@ -33,11 +33,16 @@
}
fwrite($fd, $params['contents']);
+
+ // Set the file's mtime
if (isset($params['timestamp'])) {
touch($_tmp_file, $params['timestamp']);
}
fclose($fd);
- if(file_exists($params['filename'])) {
+
+ // Delete the file if it allready exists (this is needed on Win,
+ // because it cannot overwrite files with rename()
+ if (file_exists($params['filename'])) {
@unlink($params['filename']);
}
@rename($_tmp_file, $params['filename']);
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php