php.net |  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: -
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: marco dot agnoli at me dot com Assigned:
Status: Open Package: Directory function related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
36 - 16 = ?
Subscribe to this entry?

 
 [2018-03-12 02:07 UTC] marco dot agnoli at me dot com
Description:
------------
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:
---------------
<?php

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

Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 07:01:25 2019 UTC