note 56399 added to function.touch

From: Date: Thu, 01 Sep 2005 12:09:00 +0000
Subject: note 56399 added to function.touch
Groups: php.notes 
Request: Send a blank email to php-notes+get-94594@lists.php.net to get a copy of this message
If you're going to go around deleting (unlinking) files that you don't own just in order to change the modification time on the file, you darn well better chown() the file back to it's original ownership after you are done and chmod() it back to it's correct permissions. Otherwise you will almost certainly break things. Additionally the code listed for touch()ing a file you don't own should set the file creation time back to it's original time if what is wanted is to just change the modification time. Also, the code listed will break things if there is an i/o error such as disk full or too many files in the directory. Here's how the code SHOULD be written: Create the new file FIRST, rather than last, with a different name such as $file.tmp. Read the ownership, permissions, and creation time of the old file. Set permissions and creation time of the new file the same as the old. Rename the new file to the name of the old. chown() the new file to the user that owned the file it's replacing. Please be careful adding to the documentation if you've never taken programming 101. ---- Manual Page -- http://www.php.net/manual/en/function.touch.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56399 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56399&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56399&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94594) next »