php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55124 recursive mkdir fails with current (dot) directory in path
Submitted: 2011-07-04 02:41 UTC Modified: 2017-10-24 07:58 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: [email protected] Assigned: pajoye (profile)
Status: Closed Package: Directory function related
PHP Version: 5.3.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: [email protected]
New email:
PHP Version: OS:

 

 [2011-07-04 02:41 UTC] [email protected]
Description:
------------
Running recursive mkdir fails when there is a "." directory in the path:

    <?php mkdir('a/./b', 0755, true) ?>
    PHP Warning:  mkdir(): File exists in Command line code on line 1
    Warning: mkdir(): File exists in Command line code on line 1

When a does not exist, "a" is generated, but "b" is not.
When a exists already, everything is fine.

Note that I cannot use realpath() to sanitize the path because the path does not exist yet.

Test script:
---------------



Actual result:
--------------
$ /opt/phpfarm/inst/bin/php-5.3.6 -v
PHP 5.3.6 (cli) (built: Mar 18 2011 09:27:59) (DEBUG)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

$ LC_ALL=C ls a
ls: cannot access a: No such file or directory
 
$ /opt/phpfarm/inst/bin/php-5.3.6 -r 'mkdir("a/./b", 0755, true);'
PHP Warning:  mkdir(): File exists in Command line code on line 1

Warning: mkdir(): File exists in Command line code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-26 12:57 UTC] [email protected]
-Status: Open +Status: Verified
 [2011-07-26 12:57 UTC] [email protected]
verified in ts mode at least.
 [2011-07-26 17:44 UTC] [email protected]
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=313743
Log: - Fixed bug 55124, recursive mkdir fails with current (dot) directory in path
 [2011-07-26 17:45 UTC] [email protected]
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2011-07-26 17:45 UTC] [email protected]
Fixed in 5.4 and trunk.

5.3 requires more work, can be done later but most probably post 5.3.7.
 [2011-07-26 23:58 UTC] [email protected]
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=313753
Log: - news for bug #55124
 [2017-10-24 07:35 UTC] [email protected]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2017-10-24 07:58 UTC] [email protected]
-Status: Open +Status: Closed -Assigned To: +Assigned To: pajoye
 [2017-10-24 07:58 UTC] [email protected]
Fixed since 5.4.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jun 08 11:01:26 2025 UTC