Req #76081 [Opn->Sus]: mkdir(..., ..., true) should not return false when the directory exists

From: Date: Wed, 21 Jul 2021 14:19:42 +0000
Subject: Req #76081 [Opn->Sus]: mkdir(..., ..., true) should not return false when the directory exists
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235239@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76081&edit=1 ID: 76081 Updated by: cmb@php.net Reported by: marco dot agnoli at me dot com Summary: mkdir(..., ..., true) should not return false when the directory exists -Status: Open +Status: Suspended Type: Feature/Change Request Package: Directory function related Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Either change should go through the RFC process[1]. I suspend this rticket for the time being. [1] <https://wiki.php.net/rfc/howto> Previous Comments: ------------------------------------------------------------------------ [2018-03-12 02:07:10] 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) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76081&edit=1

« previous php.bugs (#235239) next »