Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #240 mkdir() with $recursive===true doesn't support "single" directories
Submitted: 2003-11-13 19:30 UTC
From: me at mkone dot net Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: 4.3.3 OS: Suse Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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 !
Your email address:
MUST BE VALID
Solve the problem : 15 + 50 = ?

 
 [2003-11-13 19:30 UTC] me at mkone dot net
Description: ------------ If mkdir() is set up with recursive directory creation and only a simple directory is given, this directory is not be created. The problem seems to be here: [Line 290 FTP.php] while (false !== ($pos = strpos($dir, '/', $pos + 1))){ $elements[] = substr($dir, 0, $pos); } $elements is empty after that, instead of having one element. Reproduce code: --------------- $chk = $test->mkdir('path', true); var_dump($chk); Expected result: ---------------- bool(true) and directory 'path' existing on host Actual result: -------------- bool(true) directory 'path' does NOT exist

Comments

 [2003-12-31 10:48 UTC] chip at php dot net
Patch should Fix this bug. Also will now properly return an error if a subfolder in a recursive mkdir failed. --- FTP.php.dist 2003-12-31 10:42:16.000000000 +0000 +++ FTP.php 2003-12-31 10:50:56.000000000 +0000 @@ -283,13 +283,17 @@ return true; } } else { - $pos = 0; + if(strpos($dir, '/') === false) + return $this->mkdir($dir,false); + $pos = 0; $elements = array(); while (false !== ($pos = strpos($dir, '/', $pos + 1))){ $elements[] = substr($dir, 0, $pos); } foreach ($elements as $element){ - $this->mkdir($element, false); + $res = $this->mkdir($element, false); + if($res !== true) + return $res; } return true; }
 [2004-03-14 12:57 UTC] toby
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.