OSDN Git Service

BugTrack2/55: touch() before copy() is for 'rw-r--r--' instead of 'rwxr-xr-x' (with...
authorhenoheno <henoheno>
Sun, 17 Apr 2005 06:42:26 +0000 (15:42 +0900)
committerhenoheno <henoheno>
Sun, 17 Apr 2005 06:42:26 +0000 (15:42 +0900)
lib/file.php

index bbb67c3..852ad94 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: file.php,v 1.20 2005/04/17 06:16:17 henoheno Exp $
+// $Id: file.php,v 1.21 2005/04/17 06:42:26 henoheno Exp $
 //
 // File related functions
 
@@ -535,10 +535,11 @@ function pkwk_chown($filename, $preserve_time = TRUE)
 
                // Try to chown by re-creating files
                // NOTE:
-               //   * @unlink() before rename() is for Windows but here's for Unix only
+               //   * touch() before copy() is for 'rw-r--r--' instead of 'rwxr-xr-x' (with umask 022).
                //   * (PHP 4 < PHP 4.2.0) touch() with the third argument is not implemented and retuns NULL and Warn.
+               //   * @unlink() before rename() is for Windows but here's for Unix only
                flock($ffile, LOCK_EX) or die('pkwk_chown(): flock() failed');
-               $result = copy($filename, $tmp) &&
+               $result = touch($tmp) && copy($filename, $tmp) &&
                        ($preserve_time ? (touch($tmp, $stat[9], $stat[8]) || touch($tmp, $stat[9])) : TRUE) &&
                        rename($tmp, $filename);
                flock($ffile, LOCK_UN) or die('pkwk_chown(): flock() failed');