Bug #72651 [NEW]: Recursive mkdir doesn't create last directory

From: Date: Fri, 22 Jul 2016 15:49:46 +0000
Subject: Bug #72651 [NEW]: Recursive mkdir doesn't create last directory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202506@lists.php.net to get a copy of this message
From: ktierney at akamai dot com Operating system: Ubuntu 14.04 PHP version: Irrelevant Package: Apache related Bug Type: Bug Bug description:Recursive mkdir doesn't create last directory Description: ------------ (PHP5.5.9) In creating a directory using "mkdir('./results/16/07/22/G2/4', 0777, true), all but the last (4) subdirectory is created. The function returns true, no exception is thrown. This happens when the PHP script containing the line is run on an Apache2.4/7 web server. When the same function is run in interactive PHP, it works fine. safe_mode is off in both php.ini files. I substituted the CreateDirPath() function for it, but I get the same behavior on the server and interactively. Test script: --------------- $test['path'] = './results/16/07/22/G2/4'; mkdir($test['path'], 0777, true); -- and -- function CreateDirPath($dirpath, $rwx = 0777) { $x = preg_replace('/\.\//', '', $dirpath); $dlst = explode('/', $x); $cwd = $xdir = getcwd(); try { foreach ($dlst as $d) { $dt = trim($d); if ($dt) { $xdir = "$xdir/$dt"; if (!is_dir($xdir)) { if (!mkdir($dt, $rwx)) return false; } if (!chdir($xdir)) return false; } } return chdir($cwd); } catch(Exception $e) { return false; } } Expected result: ---------------- I expect all the directories to be created with a permission of 0777. CreateDirPath() does this interactively, but behaves the same as mkdir() when run under Apache. -- Edit bug report at https://bugs.php.net/bug.php?id=72651&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72651&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72651&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72651&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72651&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72651&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72651&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72651&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72651&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72651&r=support Expected behavior: https://bugs.php.net/fix.php?id=72651&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72651&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72651&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72651&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72651&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72651&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72651&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72651&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72651&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72651&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72651&r=mysqlcfg

« previous php.bugs (#202506) next »