|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76081 mkdir(..., ..., true) should not return false when the directory exists
Submitted: 2018-03-12 02:07 UTC Modified: 2021-07-21 14:19 UTC
Avg. Score:2.7 ± 1.2
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: marco dot agnoli at me dot com Assigned:
Status: Suspended Package: Directory function related
PHP Version: Irrelevant OS: Irrelevant
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: marco dot agnoli at me dot com
New email:
PHP Version: OS:


 [2018-03-12 02:07 UTC] marco dot agnoli at me dot com
It would be really useful if the mkdir function with the $recursive parameter set to TRUE would behave the same way as mkdir -p command on linux.

The difference between the two is that mkdir -p does not report an error if the directory already exists while the php version does.

And triggering a WARNING seems a bit too much, why not trigger a NOTICE or nothing at all when the directory already exists?

If backwards compatibility is a concern then we can create a new function called "mkdirp($path, $perm)".

Test script:

var_dump(mkdir('/tmp/a/b/c/d/', 0777, true));
var_dump(mkdir('/tmp/a/b/c/d/', 0777, true));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-21 14:19 UTC]
-Status: Open +Status: Suspended
 [2021-07-21 14:19 UTC]
Either change should go through the RFC process[1].  I suspend
this rticket for the time being.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC