|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49047 The function touch() fails on directories.
Submitted: 2009-07-24 12:48 UTC Modified: 2009-08-25 09:17 UTC
From: RQuadling at GMail dot com Assigned: pajoye (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3SVN-2009-07-24 (snap) OS: win32 only - Windows XP SP3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: RQuadling at GMail dot com
New email:
PHP Version: OS:


 [2009-07-24 12:48 UTC] RQuadling at GMail dot com
Trying to touch() a win32 folder fails.

In tracking this back through the source, I think the issue is that 
PHP is calling the external utime() function.

For my build (I'm a novice so please bear with me), I see that ...


are both set, but 


is not.

This is a repeat of bug#35980, but as that bug is closed and the 
example code below doesn't work, I assume this is a new bug.

So, in TSRM/tsrm_virtual_cwd.h, the call that is being made is ...

#define VCWD_UTIME(path, time) virtual_utime(path, time TSRMLS_CC)
#define VCWD_UTIME(path, time) utime(path, time)

utime(path, time)

I think this is the external call and as such will fail. I think that 
is why the virtual version exists (which in turn calls win32_utime)

Reproduce code:
$s_Directory = 'C:\\Test';
$dt_DOB = strtotime('2008-10-19 18:43');

if (file_exists($s_Directory) && !rmdir($s_Directory)) {
  die("Failed to delete $s_Directory");

echo "Create $s_Directory", PHP_EOL;
if (!mkdir($s_Directory)) {
  die("Failed to create $s_Directory");
} else {
  echo "Created $s_Directory", PHP_EOL;

echo "Touch $s_Directory : ", date('r', $dt_DOB), PHP_EOL;
if (!touch($s_Directory, $dt_DOB)) {
  die("Failed to touch $s_Directory");
} else {
  echo "Touched $s_Directory", PHP_EOL;

Expected result:
Create C:\Test
Created C:\Test
Touch C:\Test : Sun, 19 Oct 2008 18:43:00 +0100
Touched C:\Test

Actual result:
Create C:\Test
Created C:\Test
Touch C:\Test : Sun, 19 Oct 2008 18:43:00 +0100

Warning: touch(): Utime failed: Permission denied in Z:\touchdir.php on 
line 22
Failed to touch C:\Test


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-24 16:33 UTC]
commit on its way
 [2009-08-25 09:16 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - fix #49047, touch may fail on directory
 [2009-08-25 09:17 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 08 01:03:53 2023 UTC